AVCHD and Free software

I recently bought a new camera (Canon Legria HFS10). Really neat little device but, how do you use it with your Free software operating system? Well, the camera records in a new standard set my Sony and Panasonic called AVCHD or Advanced Video Codec High Definition.

What this is is a directory structure, container format and codec specification. AVCHD uses MPEG4 (or H.264 if you will) to encode video and AAC to encode audio both of these codecs are well supported in FFMpeg but the container format (called MTS) is a bit more problematic as some information appears to be missing from it. Luckily it is still possible to copy the data over and do something useful with it!

My camera records in 1080i50 default (that is 50 fields or 25 frames per second) and my computer is just not fast enough to decode that realtime, let alone edit it. This is why I resize the video to 720p and encode it as lossless motion jpeg with uncompressed PCM audio to trade CPU usage for disk bandwidth and space. The command looks something like this:

mencoder -of lavf -demuxer lavf -vf yadif,scale=1280:720,harddup -oac pcm -ofps 25 -ovc lavc -lavcopts vcodec=ljpeg /media/CANON/avchd/bdmv/stream/00000.mts -o 00000.mkv

This command will use libavformat’s demuxer and muxer code instread of mplayer’s own to be able to properly read the mts file and write the mkv file. I use MKV because the AVI container has given me many problems with editing video, seeking also seems to be much faster with MKV containers. This command will also deinterlace the 1080i50 video to end up with a 720p25 video. This is the format in which I edit my videos.

Please note that if you use the NTSC model the camera will record in 60i instead of 50i and the ‘ofps’ parameter should be set to 30 NOT 25.

If you do not need deinterlacing remove the ‘yadif’ from the -vf (video filter) same goes for scale.

And some still frames from some of the videos I’ve shot (and get with the above command line) (click for full resolution image)

Still frame from the HFS10 1

Still fram from the HSF10 2

Still frame of the HSF10 3

Leave a comment

You must be logged in to post a comment.