« »
April 23rd, 2008

LVPE: Encoding High Bitrate 24p Footage for DVD

(this post is part of the Linux Video Production Experience series, which chronicles my experiences with creating a high-quality home movie almost entirely in open source software.)

For my past movie-making adventures, I used mencoder or ffmpeg to encode my noisy, low-motion, un-color corrected video for DVD, which it happily did. There were never any huge spikes in the data, since all of the scenes were equally poor in quality. :D

And now that I’ve properly cleaned everything up and made it pretty, mencoder did not work out too well for this project, due to its not-so-good MPEG-2 rate control. ffmpeg apparently has the same problem. The issue came up with rapid scene changes or high motion video areas. Several areas in the video caused a friend’s DVD player to skip horribly, which has never happened with any of my videos before.

I needed one additional feature in my encoder this time, and that’s 2:3 pulldown. 24p footage needs to be yanked back up to 29.97fps footage so that it’s playable on most DVD players. And as far as I can tell, you can’t enable soft pulldown in ffmpeg, so that encoder’s out for this job.

Now, in my research, I’ve come across four possible open source solutions that might work:

  • Use mencoder, but specify a very low bit rate tolerance (vratetol in the lavcopts options).
  • Use mencoder with experimental Xvid rate control compiled in and enable with with vrc_strategy=1 in the lavcopts options. Xvid rate control seems to be more aggressive against the high bitrate spikes than mencoder’s libavcodec rate control.
  • Use AviSynth with QuEnc (both running in Wine), which reportedly has extremely good rate control.
  • Use Avidemux, which uses its own flavor of the Xvid rate control mechanism. Avidemux will automatically enable the soft pulldown flag if you’re encoding an MPEG-2 file at ~23.976FPS.

mencoder + a low vratetol (somewhere between 100 and 1000) still produced some very high spikes. mplex reported that the max bitrate of the stream was well over the DVD spec. mencoder also has experimental Xvid rate control, which required compiling a new mencoder. With that enabled, however, the output video stream still spikes too high.

AviSynth + QuEnc would have taken some additional work to get the AVI files I output from Cinelerra (in Motion JPEG format) to load with AviSynth. I couldn’t find a free way to get AviSynth to read MJPEG frames. Maybe I’ll have to dust off my old registered copy of the PICVideo MJPEG codec if I want to go down that road…

Avidemux WindowsAvidemux, however, got the job done. The DVD preset gets you 90% of the settings you need for DVD MPEG-2 files. Be sure to enable Xvid rate control in the DVD (lavc) settings and you should be fine. The only tricky part was joining all of the 21 movie files. If all of your final videos are alphabetically sequential in a directory, let’s say “FinalRender,” you can use this bash one-liner to open all of the files into Avidemux (which is in your path) in the right order:

cmd=”"; for i in FinalRender/*; do if [ "$cmd" == "" ]; then cmd=”–load $i”; else cmd=”${cmd} –append $i”; fi; done; `avidemux ${cmd}`

Avidemux appears to be the best way for me to encode my final, cleaned up, 24p Cinelerra AVI files to MPEG-2 DVD format to avoid skipping during playback on standalone DVD players. As usual, if I missed something in my writeup, please leave a commenton the story!

And that’s it! Please let me know if you have any comments or questions about the series. If you want to see some additional part of the process I went through for this production, let me know and I’ll find the time to post another article.

Leave a Reply