Monday, October 26, 2009

converting .m2ts/avchd from a Sony HDR UX1 to .mp4

We are testing the HTML 5 video tag. Some of the video we are trying come from a Sony HDR UX1 camcorder which records HD into .m2ts/avchd files. That give us nice, high resolution video, but it can not be played on web browsers out of the box. Current versions of three of the most popular browsers, Firefox, Safari and Google Chrome support the standard H.264 media codec. So we looked for ways to convert those videos to mp4/H.264. There are various ways to convert .m2ts files to other formats, we are currently using ffmpeg on a mature ubuntu workstation.

I'm documenting info about the camcorder in a Google Doc. The doc's currently here http://docs.google.com/View?id=dgzqtfqh_178dpxjtmfr


I installed the latest ffmpeg and the codecs it needed then used the following commands to convert from .m2ts to .mp4
  1. ffmpeg -deinterlace -i 00000.m2ts -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 15000000 -bt 15000000 -threads 0 -f mp4 -y /dev/null
  2. ffmpeg -deinterlace -i 00000.m2ts -ac 2 -ar 48000 -acodec libfaac -ab 128k -pass 2 -vcodec libx264 -vpre hq -b 15000000 -bt 15000000 -threads 0 test07c.mp4
It's not fast on my more mature pc. it took almost an hour to convert a short video. The commands above work but could be slowing it down.

I uploaded the resulting video to YouTube and it became a HD video there. I'll test with mobile, both on YouTube and our web pages and see what works best for us.