HD Video from Canon HF200 on Ubuntu Linux - convert and play

published Jan 01, 2010 01:55   by admin ( last modified Mar 07, 2016 05:21 )

Notes to self on how to play videos from the camera on my Linux computer.

The files that the Canon HD video camera outputs have the suffix MTS. These can be played by Videolan client on my Dell Celeron-equipped laptop. Well, kind of: It plays the first two frames or so, then chokes on the video and keeps playing the sound.

The mts files can be converted to other formats with ffmpeg. The video from the Canon camera seems to be interlaced. If you use ffmpeg straight off the bat like so:

ffmpeg -i canonvideo.mts -sameq video.mp4

lines will be all wavy because the canon format is interlaced. Use the -deinterlace option like this:

ffmpeg -deinterlace  -i canonvideo.mts -sameq video.mp4

Update 2016-03-07 ffmpeg tells me to use -qscale instead of -sameq:

ffmpeg -deinterlace  -i canonvideo.mts -qscale 0 video.mp4

 

The mp4 file then plays effortlessly with vlc on the computer.

It should be possible to make the output interlaced as well, with the ilme option

However this:

ffmpeg  -i 00002.MTS -sameq -flags ilme video.mp4

still creates wavy lines. There are a number of idioms with ilme in them floating around the Internet, and I am not sure how to use it.

Put together a video split in parts

Canon HF200 splits long videos in separate files, each part about 2GB in size. These files cannot be converted as individual videos! Well, the first one can, but the  following ones each depends on the one before. This is because the camera in order to save space writes incomplete frames to the files, frames that only contain the changes as compared to previous frames. Some frames however are complete on their own and are usually called key frames. Now when the camera splits the video into files, it does not take care to do this at key frames.

The video therefore before conversion needs to be put together into one large file. On Linux this can be done with the cat commmand:

cat 00001.MTS 00002.MTS 00003.MTS > whole-video.MTS