Transcoding Captured Footage

Transcoding takes an existing video file and makes another video file from it. We usually do this to make a file that seeks better and repair any problems caused by the original encoding.

For this we use ffv1 which is an ffmpeg native lossless encoder. It will generally not use more than 4 cores, so you can divide your cores by four and that’s how many files are coded in parallel, this is what -j 25% does. Check out the GNU Parallel docs for more on the options used.

For 1080p files, this will generally produce a smaller file than h264, and at a faster speed. Context 1 produces slightly smaller files.

parallel --nice 19 --filter-hosts -j 25% --bar -S Soma,Stardew,Portal ffmpeg -i {} -vcodec ffv1 -context 1 -acodec flac /mnt/LPWorking/Source/{/} ::: /mnt/LPWorking/Source/ORIG/*.mkv

There are some special cases:

For <1080p, we’ll just use h264 to get a smaller file no need for job specification as h264 uses more cores:

parallel ffmpeg -i {} -acodec flac -qp 0 -tune fastdecode /mnt/LPWorking/Source/{/} ::: /mnt/LPWorking/Source/ORIG/*.mkv

When transcoding obs captured 60000/1001 footage, due to a bug in that software not writing the framerate into the video stream, we can specify it manually with the rate option placed before the input.

ffmpeg -r 60000/1001 -i input.mkv