#!/bin/bash

# Check if ffmpeg is installed
if ! command -v ffmpeg &> /dev/null
then
    echo "FFmpeg not found. Install it first."
    exit 1
fi

# Find and convert files
find . -type f \( -iname "*.mpg" -o -iname "*.mkv" \) | while read -r file
do
    # Get output filename
    output="${file%.*}.mp4"

    echo "Converting: $file -> $output"

    ffmpeg -i "$file" -c:v libx264 -c:a aac -strict experimental "$output"

    echo "Done: $output"
done

echo "All conversions completed!"
