#!/bin/bash
# Cleanup orphaned FFmpeg files

echo "=========================================="
echo "CLEANUP ORPHANED FFMPEG FILES"
echo "=========================================="
echo ""

echo "1. Killing any orphaned FFmpeg processes..."
pkill -9 ffmpeg 2>/dev/null || echo "No FFmpeg processes to kill"
echo ""

echo "2. Removing orphaned FIFO pipes..."
rm -v /tmp/mbetterc_fifo_* 2>/dev/null || echo "No FIFO pipes to remove"
echo ""

echo "3. Removing orphaned HLS directories..."
rm -rv /tmp/mbetterc_hls_* 2>/dev/null || echo "No HLS directories to remove"
echo ""

echo "4. Removing orphaned black screen files..."
rm -v /tmp/mbetterc_black_*.mp4 2>/dev/null || echo "No black screen files to remove"
echo ""

echo "5. Checking remaining mbetterc files..."
ls -la /tmp/mbetterc* 2>/dev/null || echo "No mbetterc files remaining"
echo ""

echo "=========================================="
echo "CLEANUP COMPLETE"
echo "=========================================="