A recipe to do Cinelerra video editing with HD footage from a Panasonic HD video camera. The video format that is created by the camera is AVCHD (H.264/AC-3 audio), the files have the extension MTS. The format is also used by Sony, JVC, and Canon.
The HD format that my camera generates is 1920x1080, @50Hz progressive, with AC-3 audio.
Cinelerra is not able to import these kind of files. It is possible to do a lossless conversion of the format to a MOV container, that can be processed by cinelerra. Unfortunately composing becomes pretty slow and 'hicking' when doing this, because the decoding is a CPU intensive thing.
The solution below chooses another aproach: it first unpacks the MTS file and re-encodes it in a M-JPEG format. After that it can be seamlessly imported in Cinelerra. Composing with this format is a piece of cake, because dedoding is light-weight. The only thing that you need is a lot of disk space, and preferably fast disks (especially when you compose with multiple tracks in a single canvas). SSD's of course do the thing.
After having composed the video it must be rendered. The recipe below uses a YUV4MPEG stream render format for the video. This is lossless,requires a lot of disk space (if money matters use a spinning disk for this), but gives you the freedom to encode it later to any format you like. I'll give a suggestion in my recipe that works out fine for me.
Her is my recipe:
Convert to high quality mjpeg format. As you can see I do not care a lot about the audio. (it isn't that good anyway).
ffmpeg -i "INFILE.MTS" -vcodec mjpeg -q:a 1 -q:v 1 -ac 2 -ab 192k -strict -2 "outfile.mov"
Import all the .mov files in cinelerra, and do your editing thing.
At the end render with the YUV4MPEG stream format. In the video compression config window choose the pipe command, and type there the following:
cat > bigfile.y4m
Choose the same bigfile.y4m in the output path.
Render, this will take a while, and again it fills up your disk pretty fast.
After rendering the video also render the audio, I choose the lossless .wav format to have freedom afterwards.
To encode the video I use mencoder, 2-pass, 6Mbps h.264, as follows:
mencoder -noodml bigfile.y4m -oac mp3lame -lameopts cbr:br=192 -vf harddup -ovc x264 -x264encopts bitrate=6000:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:weight_b:pass=1 -passlogfile "passlogfile" -o "preview.avi"
mencoder -noodml bigfile.y4m -oac mp3lame -lameopts cbr:br=192 -vf harddup -ovc x264 -x264encopts bitrate=6000:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:weight_b:pass=2 -passlogfile "passlogfile" -o "myvideo.avi"
After that encode the audio in your favorite format, and mux the entire thing in the container of your choice.