Skip to content

Instantly share code, notes, and snippets.

@davidblewett
Created March 13, 2015 22:50
Show Gist options
  • Save davidblewett/fd1dc2cc2af5aeaf5493 to your computer and use it in GitHub Desktop.
Save davidblewett/fd1dc2cc2af5aeaf5493 to your computer and use it in GitHub Desktop.
Find all mpeg2 MKV files in my archive on my NAS, copy to local disk, transcode to h264.
for i in *.mkv; do
ffprobe -loglevel quiet -show_format -show_streams -select_streams v -print_format flat=h=0 "$i" | egrep 'codec_name="mpeg2video"|filename' | cut -d '"' -f 2 | tr '\n' '|'
echo
done | grep mpeg2video | cut -d '|' -f 2 > ~/mpeg2movies.txt
rsync -Pav --size-only --files-from=:/home/davidb/mpeg2movies.txt udun:/data/movies /Volumes/element/incoming
#!/bin/zsh
IN=/Volumes/element/incoming
OUT=/Volumes/element/done
for i in $IN/*.mkv; do
oname="$OUT/`basename $i`"
echo "Processing to $oname"
if [[ ! -f $oname ]]; then
ffmpeg -i "$i" -map 0 -c:v libx264 -preset slow -crf 18 -c:a copy -c:s copy "$oname"
fi
#rm "$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment