Skip to content

Instantly share code, notes, and snippets.

@hernan43
Created July 17, 2019 17:30
Show Gist options
  • Save hernan43/b58b2b99fcb112c12bddc6bb936d8574 to your computer and use it in GitHub Desktop.
Save hernan43/b58b2b99fcb112c12bddc6bb936d8574 to your computer and use it in GitHub Desktop.
I record all of my Retroarch gameplay footage into a captures directory. It starts as MKV but I like to upscale(nearest neighbor) to 5x and re-encode using FFMPEG.
#!/bin/sh
FFMPEG=/usr/bin/ffmpeg
SCALE=5
MKV_FILES=`ls /mnt/captures/**/*.mkv`
for FILE in $MKV_FILES; do
DIRNAME=`dirname $FILE`
OUTPUT_FILENAME=$DIRNAME/`basename -s .mkv $FILE`.mp4
if [ -w $OUTPUT_FILENAME ];then
echo "$OUTPUT_FILENAME exists removing..."
rm $OUTPUT_FILENAME
echo "Removed."
fi
$FFMPEG -i $FILE -f mp4 -pix_fmt yuv420p -vcodec libx264 -preset fast -acodec aac -vf scale=iw*$SCALE:ih*$SCALE:force_original_aspect_ratio=decrease -sws_flags neighbor $OUTPUT_FILENAME && rm $FILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment