Dugan Chen's Homepage

Various Things

Preparing Video for AMVs. In Linux. Part 2.

This is a follow-up to a previous entry: Preparing Videos for AMVs. In Linux.

This is how you cut out the first ten seconds of GG’s Madoka Magica fansubs in lossless HuffYUV format:

mencoder -noskip -nosound -nosub -ovc lavc \
-lavcopts vcodec=ffvhuff -ss 0 -endpos 10 \
 \[gg\]_Puella_Magi_Madoka_Magica_-_01_\[0557C1C6\].mkv \
 -o output.avi

The size of output.avi? 147M. Or almost 15mb/s, or around 21 GB per episode, 252GB for the whole season.

And this is how you convert the first ten seconds to DNxHD. DNxHD is a professional-quality editing codec for HD video. It’s designed by Avid. It’s lossy, but it’s very good. Referring to the VC3 section of an FFmpeg Howto, we see that for the resolution and bitrate we’re transcoding from (720p), we can use a bitrate of either 60M or 90M. We choose 60M.

ffmpeg -t 10 -i \
-vcodec dnxhd -b:v 60M -an output.mov

That results in an output.mov of 70mb, which is less than half the size of HuffYUV file. One episode will take up 11GB. Not surprisingly, it looks identical to the HuffYUV version.

Can we do better? Yes we can. FFV1 is lossless:

ffmpeg -t 10 -i \
-vcodec ffv1 -an output.mov

That results in a file that’s only 53MB and technically even higher in quality.

Now there’s no reason to convert the directory containing the season (or cour, if you’re enough of an otaku to call it that):

find . -exec ffmpeg -i {} -vcodec ffv1 -an \
-threads 4 {}.mov \;

These will go into kdenlive, which supports DNxHD just fine.