Tuesday, August 18, 2009

MTS, Youtube and FFMpeg

I bought a Canon HD Cam a couple of month ago for my daughter (HF20), and it has been great except it always produce .mts files. They are huge to upload to youtube, and recently sometimes after upload a video, I found the sound sometimes trembles and became very unpleasant.

So I tried to google some conversion software, and alone some pre-made commercial ones I found ffmpeg. Since economy is not good, I decided to give it a try first.

So I got ffmpeg tarball from ffmpeg.org, followed part of their build step then decided to just use cygwin. I always uses cygwin for grep, so all I have to do is add the gcc compiler, libtools, autoconfig etc. Build was simple (./configure and make).

Tried a mts file, it can't understand what x264 format is. So I grabed x264 package from videolan.org. The zip version is not good, can't configure at all. Took me a while to figure that out. Also make sure take out the -mnocygwin link option.

Tried again and it complains can't find faac. So I went downloaded faac, failed compile couple of times (__STRING not defined, and u_int32_t not defined, just define them).

Tried to compile ffmpeg again with all options, failed again. Turned out you need to remove a double defined entry in faac.h (forget what is it now).

Oh make sure you use this to config ffmpeg:
./configure --enable-gpl --enable-libx264 --enable-libfaac

Finally got it running, right now the best conversion I found is with this:
ffmpeg -i input.mts -y -target film-dvd out.mpg

Hope this helps you, and enjoy the $$ savings from video conversion software (I was going to buy one just to do mts video conversion). Big thanks to the ffmpeg team!

No comments: