Rendering video with Cinelerra and FFmpeg

I’ve been making videos to share with posts and looked around for some video editing software that works with Ubuntu. I’m running 11.10 Oneiric Ocelot and Avidemux is not yet in the repositories so I decided to give Cinelerra a try. It’s availalbe in a PPA.

I like it. I’d guess it’s got a 2-4 hour learning curve but after you figure out what commands and clicks control each function it’s pretty easy. The problem came when it was time to export my video to post on YouTube.

I tried exporting OGG files, but I got some weird errors, and only part of my video would appear when uploaded to YouTube. I needed to find an alternative. Since I’ve already compiled FFmpeg from source for transcoding my over-the-air recordings it seemed like a good choice for rendering the videos outside of Cinelerra. All I needed to do is get my hands on the raw audio and video, then use FFmpeg to assemble the parts. See the steps I took after the break.

Get the video track

Once you’re done editing, choose ‘Render’ from Cindelerra’s file menu. Choose a file name and select ‘YUV4MPEG Stream’ as the file format. Make sure that only ‘Render video tracks’ is selected.

After choosing ‘Insert nothing’ as the insertion strategy hit the green checkmark and let it do its thing.

Get the audio track

In the same render menu change over the settings to export the audio. I’ve reset the file format to ‘Microsoft WAV’, moved the check mark to ‘Render audio tracks’ and kept the same insertion strategy. Hit the check mark and we’ll have the files we need.

Put it all together with FFmpeg

Now this is easier said than done. I tried just throwing the two together and was very unhappy with the video quality that resulted. I Googled around and came up these settings which produce a fairly good result:

ffmpeg -i input.m2v -i input.wav -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -bf 2 -flags mv0 output.mpg

Here’s the video, it uploaded to YouTube without a hitch. Now granted this used 500×300 pixel slides to start with. But the quality of the mpeg that resulted from this transcoding closely matches that of the raw video so I’m happy.

I’m still waiting to get my hands on an HD video camera. It’ll be interesting to see if these FFmpeg options work at those resolutions.

essential