dscn1233.JPGThis holiday season, I was an extremely lucky recipient of a Sony HDR-SR5 video camera with a whopping 40GB hard drive inside.

When I opened it, the first question in my head was not atypical of a Linux users’ train of thought:

“Is it compatible with Linux?”

The answer was a tiny bit more complicated than I imagined, and immersed me into the otherwise unknown world of video transcoding, which is something millions of people do every day but probably never think about it. The best example is on YouTube, where it happens behind the scenes in the Google computing cloud, and everything “just works.”

I’ve read a few things about the format the camera uses, called AVCHD. Even in Windows (or OSX for that matter) many people have headaches with the AVCHD format, so I figure that Linux users are probably going to be having a helluva time trying to get it to work.

The files the camera generates are compressed at an incredible 15:1 ratio. I’ve seen it mentioned that a Standard Definition compressed clip of is actually larger in file size than an HD clip in AVCHD format.

The compression is where a majority of the AVCHD format complaints come originate from, since there is not much out there in terms of being able to edit video stored in the format without uncompressing it first. It takes some rather respectable computing horsepower to actually convert the files into an uncompressed format that can be played with in a video editing software package. Using the method detailed here, it takes about 5-6 minutes to uncompress and transcode a minute of video, on an Intel Core2Duo running at 3.2GHz with 4GB of RAM and a 10,000RPM hard drive – OUCH!

When plugging in the Sony HDR-SR5, it functions as a USB Mass Storage Device. Copying files from the camera to the computer is a simple drag n’ drop affair. This would be a familiar process to anyone who has used a digital camera and imports pictures to their computer.

It would certainly be faster to playback the videos in real-time and capture them using the component outputs from the camera… but that wouldn’t be a challenge. I’ve never actually installed the software that came with the Sony Handycam, so I’m not sure what I’m missing out on, but it doesn’t seem like all that much, to be honest. I wouldn’t be surprised if it was the typical Sony software suite that is about as useless as the media it is distributed on.

Let’s get down to the meaty bits, shall we?

The first thing I searched for was “AVCHD Linux” and found a post over at AVS Forum. On a side note, my Google-Fu is really spot on lately.

That post is a gold mine. It literally contains everything we need to transcode the video into formats of our choosing that are usable in non-linear video editing programs such as Avidemux or Cinelerra.

m2tstoavi is the best information I have found (so far!) to uncompress the AVCHD video files on my camcorder and convert them into a .AVI file in Linux.

Installation is very simple, all it requires in Ubuntu is a quick apt-get install:

sudo apt-get install mplayer ffmpeg x264 faad2 faac a52dec mencoder faad libfaad2-0 libfaad2-dev subversion csh

Then edit the install script as noted in the README to grab the newest version of ldecod. Everything else is completely automated – nice job Axel!

I did need to modify the settings a tiny bit to actually get audio synchronized as well as fix a possible issue with the script itself. I had problems until I commented out the echo ffmpeg yadda yadda part. When modified, it runs the following commands:

xporthdmv -hn $file 1 1 1 && mv bits0001.mpa $audiofile
ldecod -i bits0001.mpv -o $videofifo &
ffmpeg -r 29.97 -s 1440x1080 -i $videofifo -i $audiofile -vcodec mpeg4 -sameq -acodec copy -aspect 16:9 -b 15000k

I’m using the m2tstoavi.fifo script that uses named pipes (denoted above with dollar signs) to stream the output of one command into another. It is efficient with disk space and does not fill up the drive as the regular m2tstoavi script does, not sure why the fifo version is not the default. Ah well, nothing is perfect.

Once installed, I just run this command to convert every MTS video in the current directory to .AVI files:

./m2tstoavi.fifo *

It turns this proprietary format mess:

source-mts.png

Into precious memories:

output-mts.png

All in all, I’m glad I don’t need proprietary software for this conversion. I really wish it were faster – but here’s the point of this exercise:

I never used Windows software, so I don’t know what I’m missing. I’m happy with the solution I have, and if 20 people comment on this post and say they can edit HD video in realtime, good for them.

If they do, then I would have a better reason to upgrade to a quad-core CPU.

Here’s a (VERY unpolished!) video talking about the process in a little bit more detail, and showing the actual encoding process and the finished result. I’m not responsible for anybody tripping out at the end on my extremely crazily bad camera skills in the rendered video.

Oh yeah, and for those of you who were wondering, I also received quite possibly one of the best books I’ve read in a long time… it’s all about how cool Eric S. Raymond is ninjas are.

ninja.png



Are you interested in FREE SUBSCRIPTIONS for qualified professionals to eWeek, PC Magazine, PC World, and many more? Click here!

Tags: , , , , , , , , , , , , , ,


117 Comments to “Transcoding MTS/M2TS AVCHD Video Into AVI Files with Free Software”

  1. Colin Dean | January 3rd, 2008 at 12:18 pm

    DO WANT.

  2. Wayne | January 3rd, 2008 at 1:21 pm

    It’s a sexy HD camera if I do say so myself.

  3. Iván | January 4th, 2008 at 8:54 am

    DO WANT (the book, not really interested in cameras :P )

  4. Bob Robertson | January 4th, 2008 at 3:24 pm

    If you want Ninjas, then study Ninjutsu:

    http://www.winjutsu.com/

    I find it much more natural in movement, less “stiff” than generic Karate, yet with a much greater range of skills and style. Check out Human Weapon #14 for a glimpse.

    On video, wow! 1 to 5 speed ratio on that hardware? I’m not going to be getting a Sony, that’s fore sure.

    I was very happy with my Sony mini-DV camera until it broke, it interfaced with Linux seamlessly. Linux runs fine on my Sony laptop, so it’s nothing against Sony.

  5. Wayne | January 4th, 2008 at 3:27 pm

    Pinnacle has a product for Windows that transcodes and renders the timeline in real-time.

    So yeah, I am missing out. *shrug*

    -Wayne

  6. Eugenia | January 4th, 2008 at 6:49 pm

    FYI, please read the comments too:
    http://eugenia.gnomefiles.org/2008/01/04/canon-avchd-24p-pulldown-removal/

    If you can test for me a few things, I can add Linux in the tutorial. Please let me know if you are available to help out.

  7. adam | January 4th, 2008 at 10:08 pm

    looks like you made it to the front page of digg again, via wired…
    congratulations!
    this is my favorite linux blog

  8. Unatine :: blog : links for 2008-01-05 | January 5th, 2008 at 5:30 pm

    [...] Transcoding MTS/M2TS AVCHD Video Files with Free Software | fsckin w/ linux Tags: none January 6, 2008, at 4:30 — links — BY-NC-SA [...]

  9. Daniel | January 6th, 2008 at 9:42 am

    Hey thanks for another great post! I am curious if this process could be sped up with the addition of a graphics card that would handle h.264 encode/decode. For instance the 8000 series nvidia cards have pureHD which off loads most of the decode/encode labor.

    If you continue to test different methods please update us with your progress

  10. cf | January 6th, 2008 at 2:33 pm

    Thanks a bunch! Finally got a couple vids off my new camera thanks to you (and Mr. Olmos & a host of others) with the mighty Gutsy Gibbon of Ubuntu.

  11. Wayne | January 6th, 2008 at 5:32 pm

    cf: That’s great!

    Daniel: I’m pretty sure that it is theoretically possible, but I’m not sure that the decoding ability of the video card has been harnessed yet… it would certainly be much faster with a dedicated device.

  12. Jason | January 7th, 2008 at 1:40 am

    How happy are you with the video quality? Is it worth getting one of these cameras? Is the video de/re compressed or is it only the container that’s modified?

  13. Wayne | January 7th, 2008 at 2:20 am

    Jason: Low-light video is noisy. Otherwise I would say it is the most compelling product in its price range next to the Canon models.

    It has me seriously considering a 24 or 27″ monitor to be able view the output natively on my computer. It looks terrific on my HDTV.

  14. Tavo | January 7th, 2008 at 10:58 am

    I think there is no support in linux drivers for decoding h264 video (and of course encoding) with videocard’s hardware, just for decoding mpeg2.

  15. Thomas Westin @ DSV » AVCHD conversion | January 9th, 2008 at 3:02 pm

    [...] General info [...]

  16. Scott | January 12th, 2008 at 1:58 pm

    Yeah only mpeg2 hardware decoding in Linux with Nvidia at the moment. The cards can do h.264 in Windows, so it’s a matter of the driver. :( Linky: http://forums.nvidia.com/index.php?showtopic=35698

  17. cf | January 14th, 2008 at 6:14 am

    and now to see if we can get them on to a video ipod

    http://ubuntuforums.org/showthread.php?t=114946

    https://help.ubuntu.com/community/Medibuntu

  18. Yuri Gorokhov | January 26th, 2008 at 12:01 pm

    Hey guys I have a Question.

    I am following the directions above as I am trying to convert an MTS file to an avi from my Sony HDR7 on Ubuntu.
    I am entering the following commands :

    xporthdmv -hn $file 1 1 1 && mv bits0001.mpa $audiofile
    ldecod -i bits0001.mpv -o $videofifo &
    ffmpeg -r 29.97 -s 1440×1080 -i $videofifo -i $audiofile -vcodec mpeg4 -sameq -acodec copy -aspect 16:9 -b 15000k

    But I have NO luck getting the video synchronized with the audio. The audio keeps lagging behind. Does anyone have any idea on what I am doing wrong?

    Also, anyone know if there is any tool to edit HD video directly? Is there any work being done on that?

    Thank you!

    Yuri

  19. Adam Theo | January 26th, 2008 at 3:40 pm

    The same as Yuri above, and the author of this article, I am having audio/video sync problems with the resulting .avi file. The tutorial mentions commenting out a “echo ffmpeg” line, but where exactly is this? And I want to mak sure this commenting out is the solution to the sync problem. Thanks.

  20. Wayne | January 28th, 2008 at 1:44 am

    Yuri / Adam – if you have a PAL camera, this may fix it:

    ffmpeg -r 25 -s 1440×1080 -i $videofifo -i $audiofile -vcodec mpeg4 -sameq -acodec copy -aspect 16:9 -b 15000k

    The video is being encoded at 25 vs 29.97 frames a second

  21. Yuri Gorokhov | January 28th, 2008 at 10:31 am

    Thanks for the input, but no that didn’t solve the problem

  22. Adam Theo | January 28th, 2008 at 12:58 pm

    I don’t think I have a PAL camera, but I’ll try your suggestion in a few minutes.

    I’m still having the trouble with the scripts, but I *did* get it working perfectly when entering the commands manually on the command line in some fashion. I did this late, late last night, when half asleep, so I hope I wasn’t dreaming it.

    I’ll now try to reproduce it, and detail the steps in my next post in an hour.

  23. Adam Theo | January 28th, 2008 at 3:27 pm

    An update: I was wrong.

    But thankfully wrong in a good way: it works fine with both manual and the fifo script. I have run it many times, changing many options around to make sure I really do have a good configuration.

    To note: I installed the latest CVS ffmpeg with the following ./configure flags:
    –enable-gpl –enable-pp –enable-pthreads –enable-nonfree –enable-libvorbis –enable-libtheora –enable-liba52 –enable-libgsm –enable-libdc1394 –disable-debug –enable-shared –enable-libxvid –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-libmp3lame –enable-libx264 –enable-x11grab –enable-swscaler –enable-nonfree –prefix=/usr/local

    And here are some other stats for ffmpeg’s installation:

    libavutil version: 49.6.0
    libavcodec version: 51.49.0
    libavformat version: 52.5.0
    libavdevice version: 52.0.0
    built on Jan 28 2008 01:23:48, gcc: 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)

    And here is the middle section of my m2tstoavi.fifo script (middle because I’ve commented out and changed many parts)

    if ( ! -f $audiofile ) then
    # echo xporthdmv -hn $file 1 1 1
    xporthdmv -hn $file 1 1 1 && mv bits0001.mpa $audiofile
    else
    echo $audiofile already exists, not creating it.
    endif

    mkfifo $videofifo
    # echo ldecod -i bits0001.mpv -o $videofifo
    ldecod -i bits0001.mpv -o $videofifo &

    if ( ! -f $outputfile ) then
    # echo ffmpeg -r 29.97 -s 1440×1080 -i $videofifo -i $audiofile \
    # -vcodec mpeg4 -sameq -b 15000k \
    # -acodec libmp3lame -ac 2 -ab 256000 \
    # $outputfile
    # First pass for statistics
    ffmpeg -r 29.97 -s 1440×1080 -i $videofifo -i $audiofile \
    -vcodec mpeg4 -aspect 16:9 -sameq -b 15000k \
    -acodec libmp3lame -ac 2 -ab 256000 \
    -pass 1 -passlogfile $filebase $outputfile || exit 1

    # Second pass for better quality… I hope
    ffmpeg -r 29.97 -s 1440×1080 -i $videofifo -i $audiofile \
    -vcodec mpeg4 -aspect 16:9 -sameq -b 15000k \
    -acodec libmp3lame -ac 2 -ab 256000 \
    -pass 2 -passlogfile $filebase -y $outputfile || exit 1
    else
    echo $outputfile exists, not creating it.
    endif

    I hope this helps someone, and since I am by no means an ffmpeg expert, if someone sees me doing something wrong in any of this, please let me know!

  24. Adam Theo | January 28th, 2008 at 7:05 pm

    Well, a change: I spoke too soon when I said my above script works. It stalled at the 2nd pass. I’ve changed it by removing the 2nd block of ffmpeg and the “-pass” references. It now works perfectly, verified after half a dozen videos in a row.

  25. Wayne | January 28th, 2008 at 9:27 pm

    Sweet! How long is it taking to encode the videos?

  26. Adam Theo | January 28th, 2008 at 10:17 pm

    I have a bunch of little videos, each only 1 to 3 minutes long, encoded in 7 mb/s bitrate (half the full High Def bitrate), resulting in MTS files around 35-80 MBs in size. It is taking about 7-14 minutes to process each one, I *estimate*, but note I am doing this on a relatively slow laptop (1GB RAM, Pentium Dual Core 1.8 GHz). I have a server I’m in the process of setting up, and I hope that might be a little better (that’ll be a dual processor Xeon 64 bit with 1GB RAM).

  27. Adam Theo | January 28th, 2008 at 10:20 pm

    Oh, and the resulting mpeg4 avi file is about 75% of the size of the original MTS file. Is this *reduction* in size normal? I thought the AVCHD formt was highly compressed, and that any re-encoded video would be significantly larger. Am I unwittingly reducing the quality somewhere along this process?

  28. Adam Theo | January 28th, 2008 at 10:23 pm

    Oh, and another thing (sorry to fill up your feedback forum here), but I had trouble with the ac3 audio encoding. No errors were reported, but neither VLC nor Totem played audio when I would play back the AVI (video was fine). I switched to the libmp3lame (mp3), and it works perfectly.

  29. Wayne | January 28th, 2008 at 11:41 pm

    For me, 3.5GB of HD video in .mts format converts to 14.6GB. So roughly 4x larger after they’re converted. You might be loosing quality.

    I’m not much of an ffmpeg expert by any stretch of the imagination, perhaps at this point starting a thread on doom9 forums or even the ffmpeg users mailing list would be highly beneficial for all of us.

  30. Yuri Gorokhov | January 29th, 2008 at 9:39 am

    Thanks a lot adam! your solution solved my problem completely!

  31. Adam Theo | January 29th, 2008 at 3:23 pm

    Yuri, glad it worked. Question: what are your file sizes looking like? As I mention above, I’m having an odd result, but I realized this might be because my videos are all “bluescreen”, where most of the background is a stationary solid color, and therefore mpeg4 might be compressing that, resulting in the small file size.

  32. Yuri Gorokhov | February 3rd, 2008 at 1:38 am

    Hey Guys,

    The files are working out great, except I noticed that Cinelerra will not recognize any of the AVI files that I create. I have tried multiple codecs such as XVID and VORBIS, but no luck. The LIVES editing program works fine. Any ideas why cinelerra won’t work with these files?

    Thanks,

    Yuri

  33. Ramana | February 6th, 2008 at 11:40 am

    I used the steps outlined in the thread and was able to convert MTS to AVI – but I see audio video sync problems.
    Audio seems to be out by a few seconds.

    I tried to use the “-acodec libmp3lame” but it does not work inspite of compiling ffmepg with ‘libmp3lame’.

    Any ideas?

    Thnaks,
    Ramana

    % /usr/local/bin/ffmpeg -formats | grep mp3
    FFmpeg version SVN-r11872, Copyright (c) 2000-2008 Fabrice Bellard, et al.
    configuration: –enable-libmp3lame –enable-liba52 –enable-gpl
    libavutil version: 49.6.0
    libavcodec version: 51.50.0
    libavformat version: 52.7.0
    libavdevice version: 52.0.0
    built on Feb 5 2008 21:29:17, gcc: 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
    DE mp3 MPEG audio layer 3
    EA libmp3lame
    D A mp3
    D A mp3adu
    D A mp3on4
    text2movsub remove_extra noise mov2textsub mp3decomp mp3comp mjpegadump imxdump h264_mp4toannexb dump_extra

  34. Slacy’s Blog » Blog Archive » Transcoding MTS/M2TS AVCHD Video Into AVI Files with Free Software | February 9th, 2008 at 1:46 pm

    [...] Transcoding MTS/M2TS AVCHD Video Into AVI Files with Free Software [...]

  35. slacy | February 12th, 2008 at 8:12 pm

    The current top-of-truck version of mplayer/mencoder from SVN can properly decode and transcode .mts files from a Canon HG10 into other formats.

    For example, after compiling a new mencoder, I’m using the following single commandline to scale the .mts files down to something that will decode in realtime on my PC:

    ./mencoder /tmp/00126.mts -o /tmp/00126.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000 -fps 60 -vf scale=800:450

    There’s no A/V sync issues either!

  36. Travis | February 24th, 2008 at 10:28 pm

    I’m trying to get this to work in Ubuntu 7.10, what am I doing wrong?

    travis@travis-ubuntu:~/Desktop/m2ts$ ./m2tstoavi.fifo samplevideo.m2ts
    bash: ./m2tstoavi.fifo: /bin/csh: bad interpreter: No such file or directory

  37. Wayne | February 25th, 2008 at 12:10 am

    you need to install the c shell interpreter:
    sudo apt-get install csh

  38. Travis | February 25th, 2008 at 7:44 am

    @Wayne – that makes sense, thanks!

  39. Wayne | February 25th, 2008 at 1:28 pm

    Yeah sorry about that, I updated the article apt-get line so it’ll install it. :) Whoops!

  40. Travis | February 25th, 2008 at 7:52 pm

    Awesome! Works like a charm now. What sources do you have in your /etc/apt/sources.list? For some reason, mine failed to get faad2.

    You don’t happen to know how to deinterlace the video too do you? The interlacing in the video from my Canon HG10 is very obvious.

    Thanks again for this guide and your help!

  41. Travis | February 25th, 2008 at 8:47 pm

    Cool, I just needed to modify the ffmpeg command to add -deinterlace and -aspect 16:9

  42. Wayne | February 26th, 2008 at 2:09 pm

    I noticed faad2 doesn’t get too. Not sure why I had it in the list. Unfortunately, my Sony cam uses adaptive interlacing – if a scene has lots of movement it interlaces, if its a still shot, none. I’m waiting for the next crop of 1080p non-interlacing, true “progressive” cameras to come out. Several were shown at CES this year by cannon and samsung and others.

  43. Hans | March 21st, 2008 at 3:23 pm

    Hi,
    i use “MEncoder dev-SVN-r26268-4.1.2″ (compiled on a P4/2GHz Xubuntu edgy) with this options

    mencoder 00001.mts -o 1.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=10000 -fps 60 -vf scale=1140:1080

    and it works fine & fast. My Cam is a Panasonic HDC-SD5.

    Install Mencoder (MPlayer):

    get codecs from http://www.mplayerhq.hu/design7/dload.html and install

    svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
    ./configure
    make
    make install

    (maybe ln -s /usr/local/bin/mencoder /usr/bin/mencoder)

    Thats all.

  44. kert | March 31st, 2008 at 3:35 am

    yup latest svn of mplayer demuxes and decodes MTS .. you can even play them straight, sort of, without reencoding

    straight remuxing without reencoding to mp4 also works, but then player needs to have decoder that understands interlaced and highprofile h264 stream.. very few of them do.

  45. Rick Rinehold | May 11th, 2008 at 6:25 pm

    I have a .mts file that is the first of 2 that were broken in 2 during a 1 hour video. There are 2-2 gig files and one less than 2. With that being said, the first of the 2 gig files I cannot open In my Sony Vegas 7 edit software. Ive been using this camera for a year and never had this issue before. How or can I get this file repaired. I’ve said enough…sorry for being so long winded! Please help if you can, very important video lost!
    Rick

  46. Blog forside | May 15th, 2008 at 12:31 am

    [...] Det kan gøres med Super (se på Softwaresiden under videolykke), DGAVCdec og et par andre programmer/metoder. Det tager også tid og er svært, men er måske den bedste løsning for [...]

  47. Yuri Gorokhov | May 24th, 2008 at 12:04 pm

    Hey,

    I am running the following ffmpeg line for the conversion :

    ffmpeg -deinterlace -r 29.97 -s 1440×1080 -i $videofifo -i $audiofile -vcodec mpeg4 -sameq -acodec aac -ac 2 -ab 256k -aspect 16:9 -b 15000k $outputfile

    But the resulting video has really annoying slow lines running down the screen. Especially when there is motion in the video.

    Any ideas…?

    Thanks

  48. geoffrey | June 2nd, 2008 at 9:05 pm

    rename the .mts to .mpg and do what you want with it

  49. Travis | June 2nd, 2008 at 9:10 pm

    @geoffrey, if only it were that easy, haha

  50. Travis | June 2nd, 2008 at 9:12 pm

    @Yuri it sounds like your video isn’t getting de-interlaced properly

  51. geoffrey | June 2nd, 2008 at 9:18 pm

    it is that easy try it and see

  52. Travis | June 2nd, 2008 at 9:20 pm

    I just did and neither VirtualDub nor Windows Movie Maker could open it.

  53. geoffrey | June 2nd, 2008 at 9:46 pm

    windows media player works with it

  54. geoffrey | June 3rd, 2008 at 1:32 am

    add this codec Haali Matroska Splitter to your system

  55. Cbotelho | June 7th, 2008 at 8:15 am

    It’s not working with ubuntu 8.04…help-me!

  56. peddu | June 24th, 2008 at 12:52 pm

    Here is how you do it in windows xp..
    http://eugenia.gnomefiles.org/2008/05/04/avchd-transcoding-using-free-tools/

    Can convert to any format that super can handle. Converted 2 min m2ts video to DVD vob (the website explains converting to mp4, but you can select any other output format in super), took about 20 min.

    hope it helps,
    peddu

  57. .mt2s video file conversion Kit for Linux/Unix/Mac OS X « | July 2nd, 2008 at 12:38 am

    [...] http://www.fsckin.com/2008/01/03/transcoding-mtsm2ts-avchd-video-files-with-free-software/ [...]

  58. Britt | July 4th, 2008 at 2:19 am

    I have actually read this book cover to cover and Robert Hamburger is a genius. I am glad to see that others think so too. Thanks for the software… I would donate money but I don’t see a link… add one!

    Britt

  59. Saif | July 23rd, 2008 at 2:26 am

    What about converting it onto something that a BluRay player will read? Which software for Win XP?

  60. Saif | July 23rd, 2008 at 2:27 am

    What if you simply wanted to put it on DVD-R in HD format for non-BluRay players & on a BDR for play in a BluRay player.

    Thanks

  61. James | August 2nd, 2008 at 10:44 am

    When I try to run the apt-get line, I am having trouble. It appears that ffmpeg depends: libmp3lame0 and mplayer depends: liblame0, but libmp3lame0 conflicts: liblame0. Am I doing something wrong?

  62. Dany | August 21st, 2008 at 5:57 am

    It’s not working with ubuntu 8.04 ..anyone..?

  63. Dennis | August 22nd, 2008 at 11:49 pm

    I use this guide to convert avchd pal to mpeg4 matroska:
    http://linux-tipps.blogspot.com/2008/08/hd-video-encoding-in-sync-with-ffmpeg.html

    It works quite well and fast under Ubuntu 8.04.

  64. Hans | August 23rd, 2008 at 1:24 am

    Thanks Dennis! Works fine on my Kubuntu 8.04 (2.6.24-19 AMD64)

  65. Doug | September 7th, 2008 at 9:30 pm

    What software other than iMovie can you use to pay MTS video files created by my Sony SR12?
    Thanks
    Doug

  66. AVCHD video processing « My tech blog diary | September 11th, 2008 at 7:42 am

    [...] http://www.fsckin.com/2008/01/03/transcoding-mtsm2ts-avchd-video-files-with-free-software/ [...]

  67. Matus from Kaypax | September 20th, 2008 at 10:42 pm

    Here is AVCHD VIDEO EDITOR for UBUNTU and other Linux systems: http://cinelerra.org/about.php and http://www.heroinewarrior.com/cinelerra.php3

  68. gordonmcdowell | September 25th, 2008 at 8:40 am

    So once you’ve transcoded the video, what is your final video editing solution? I use Vegas 8 (under XP) and find it edits AVCHD ok in realtime (on a dual core), but it certainly taxes the machine. However, the Aiptek cameras which record MOV files in H.264 not only require exporting from QuickTime to MP4 (due to a gimped audio format… its the audio which requires the export not the picture data), but can NOT be edited smoothly in realtime. I’ve got a quad core Dell XPS 430 and multi camera editing of 2 Aiptek 720p videos results in 1-frame-per-second updating in my editor. Crazy slow.

    My point being even if you get a top-of-the-line PC, the cameras seem to be employing video compression which requires more and more power to decompress on the fly. It may be transcoding for responsive editing (like you have done) becomes the norm.

    (But once again in case it was lost in this rant, what do you use to edit?)

  69. Robbie | October 3rd, 2008 at 8:14 am

    Doug, VLC media player for both Linux and Windows should play your files. And pretty much anything else too!

    It has many CODECs built in so other changes to CODECs on your system will not affect your ability to play video files.

    Rob

  70. gordonmcdowell | October 3rd, 2008 at 8:26 am

    Doug (and Robbie), my experience with VLC player is for some reason it does not play footage captured on my SONY HDR-SR1, often closing with an error. If anyone (Robbie?) has used it to play AVCHD footage captured with this camera and thinks the problem is me, please lemmie know!

  71. Robbie | October 4th, 2008 at 12:08 am

    Sorry to disappoint Gordon, the files I’ve played with VLC are not from this source so can’t confirm experience with that data. Good luck in your search for a solution.

  72. The Most Beautiful Smile In The World « This week in panospace | October 30th, 2008 at 9:34 pm

    [...] media players available in Ubuntu seems to work at the time of writing. For editing, there are workarounds, but I end up fiddling too long with conversions and not enough with the actual editing. Video [...]

  73. ssnfang | November 27th, 2008 at 8:08 pm

    iSkysoft Video Converter for Mac is a professional Mac Video Converter.It can convert video files from one format to another format and convert video to audio for Mac OS X users
    Download here: http://www.mac-video-converter.com

  74. Ajay | January 10th, 2009 at 11:23 pm

    I think KDEnLive http://kdenlive.org/ is a pretty good alternative. All I did was use package manager to install kdenlive, start it, import my clips, add clips to time line, export to DVD.

    Its still exporting… Things are looking good though.

    Good luck.

  75. Robert Forsman | January 26th, 2009 at 7:11 am

    I’m going to jump to the conclusion that the A/V sync issues are caused because the tool chain does not honor the time stamps on the original video. MPEG video and audio packets almost always have time stamps (PTS/DTS) which exist specifically to synchronize audio and video. If a demultiplexer strips these off, the multiplexer will not know what the exact skew between the two is and the final video will be out of whack. In order to have proper A/V sync every filter in the chain has to respect and preserve time stamps.

  76. Transcoding AVHD (Cannon HF100 .mts) into a usable open format (MKV w/ FFMPEG) « Init | February 15th, 2009 at 8:45 pm

    [...] Transcoding MTS/M2TS AVCHD Video Into AVI Files with Free Software (fsckin w/ linux) [...]

  77. links for 2009-02-20 « Where Is All This Leading To? | February 20th, 2009 at 4:13 pm

    [...] Transcoding MTS/M2TS AVCHD Video Into AVI Files with Free Software | fsckin w/ linux (tags: software video linux hd ubuntu editing conversion avchd mts m2ts) [...]

  78. Ian | February 21st, 2009 at 5:13 am

    I dont get this! xport is a .exe file??? this is Linux and those dont work. How did you get this to run?

  79. Ian | February 28th, 2009 at 1:40 pm

    Hey I got it working a while ago but forgot to comment back. This is great. I’m having the audio sync problem. Is the problem fixed if you put -hn in the xporthdmv command? I’m using just a -h because in –help there is no -n option. Sooo. What is the consensus on the sync problems?

  80. Ian | February 28th, 2009 at 4:46 pm

    Audio sync problem with Mencoder FIXED…

    just add “-of lavf” right before “-o outputfile” in your encoding command.

    *drop all quotes when using this advice.

    : )

  81. Hans | March 1st, 2009 at 1:40 am

    Hi Ian,
    do you can post a full example with your Mencoder options? Thanks!

  82. Ian | March 1st, 2009 at 11:44 am

    I use a fully modified version of the script. I’ll put up a download for you later sorry I have no time right now…

    also, I am still perfecting a couple of things…

  83. Loris | March 28th, 2009 at 8:24 am

    I also had the audio sync pb.

    http://ubuntuforums.org/showthread.php?t=1045153

    gave an easy mencoder based solution:
    mencoder 00001.MTS -o 1.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=10000 -fps 50 -vf scale=1280:720

    (this is for PAL/Europe. For NTSC/states change -fps 50 to -fps 60000/1001)

  84. Mike | April 2nd, 2009 at 8:23 am

    I have read several articles about tyransfering HD video to a format that my computer can reaqd, my mate had a Sony HD camera on holiday last year and I am trying to read the disc he has sent me. So far I have only nread a lot of rubbish, it is full so full of abreviations that I don’t know what I am looking at. If this is a sample of this website, I am sorry, it is a complete load of Cr**. Sory for the invective but I saw it on a previous section and thought it was appropriate.

  85. Taffy Boyo | April 11th, 2009 at 5:50 am

    Is there any software out there that leverages the massive parallel computational capabilities of the AVIVO system that ATI/AMD use in their HD48xx systems?
    I have one of these and want to process AVCHD in it’s uncompressed form. A program that can use the AVIVO system and runs on Linux and Vista would be awesome.

  86. Hans | April 17th, 2009 at 12:25 am

    I can highly recommend KDENLIVE to cut, convert and render MTS-Files (AVCHD). For me it’s simply the best OpenSource Videoeditor and a good replacement for Mainactor for Linux.

    http://www.kdenlive.org/

  87. Gordon McDowell | April 17th, 2009 at 9:05 am

    Hans, I’ll back you up on that (KDENLIVE = GOOD), although I have not edited a full project on it yet. My issue was being unable to capture HDV via firewire on my Ubuntu box. I don’t know if that was an issue with KDENLIVE or my OS install. But in terms of supporting a wide variety of footage, KDENLIVE took EVERYTHING i could throw at it.

    My only concern was that it appears a bit slow playing AVCHD… like SONY VEGAS was a bit more responsive in playing back the same footage. But then Vegas costs serious $, and is having trouble is Aiptek 720p files >2GB (which KDENLIVE does not have trouble with).

    I’m looking for a free video editing solution for schools, and I’ll be checking out KDENLIVE again on my next install of Ubuntu. I’m told there are multimedia Ubuntu distributions, so I’ll probably try start with a fresh install of one of those.

  88. Hans | April 17th, 2009 at 12:01 pm

    Hi Gorden,
    i recommend to install ubuntu jaunty (final release date is 09/04/23) which includes a lot of necessary patches for kdenlive, ffmpeg, mlt, etc.. it works fine with my panasonic hdc-sd5. are you a teacher, too?

  89. Gordon McDowell | April 17th, 2009 at 12:14 pm

    No, but wife is principle of a school, and I’m volunteering some time to help them set up editing suite. Windows Movie Maker being what it is. I’ll let let Jaunty come out and try again with that. Thanks.

  90. luismanolo | April 29th, 2009 at 12:32 am

    See this (in spanish):

    http://www.aulir.com/wiki/index.php/Convertir_v%C3%ADdeo_de_formato_HD(AVCHD)_-*.mts-_a_QuickTime_-.mov-_para_editar_con_Cinelerra_o_Final_Cut

  91. mrucs | May 29th, 2009 at 6:07 am

    I’ve got a number of files .avi .mpeg etc I want to put onto a AVCHD disc, but I need to convert them into the correct directory structure i.e. BDMV and CERTIFICATES etc any app that does it?

  92. Ian | May 29th, 2009 at 8:26 am

    There’s such thing as an AVCHD disc?

  93. mrucs | May 29th, 2009 at 4:14 pm

    Yeah, you can make a AVCHD DVD, which uses the BBMV and CERTIFICATE folders like a blu-ray disc.

    This allows you to have higher then 720p resolution on the disc, you obviously need a blu-ray player to play the disc though.

  94. Ian | May 30th, 2009 at 8:59 am

    oh that actually sounds really cool. So its basically like putting dvd video on a cd?

    i wish i had a blue ray player. they’re too much.

  95. Andrew | June 26th, 2009 at 7:51 pm

    Dude, take that video out. Good article and completely “like total” level of commentaries eehhmm, ha, mmm like you know…. Terrible! Take it off!
    Andrew

  96. Ian | June 26th, 2009 at 8:23 pm

    what are you talking about?

  97. Joe | July 16th, 2009 at 6:46 am

    Ubuntu 9.04:

    $ sudo apt-get install mplayer ffmpeg x264 faad2 faac a52dec mencoder faad libfaad2-0 libfaad2-dev subversion csh
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    ffmpeg is already the newest version.
    Package faad2 is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    However, the following packages replace it:
    faad
    E: Package faad2 has no installation candidate

  98. badger | August 3rd, 2009 at 5:31 pm

    For Transcoding AVCHD Video MTS/M2TS Into AVI Files with Free Software. I use a program called HD Converter for Mac. You can download a free Demo version at
    http://www.flash-video-soft.com/hd-converter/

  99. gary | August 10th, 2009 at 4:51 am

    for Ubuntu 9.04:

    sudo apt-get install mplayer ffmpeg x264 faad faac a52dec mencoder faad libfaad2-0 libfaad-dev

  100. Megit | August 13th, 2009 at 12:40 am

    I would stick to iSkysoft video converter that makes much easier when editing AVCHD video with Abode premere CS4.
    http://www.hd-dvd-ripper.net/video-converter.html#139

  101. moore | August 15th, 2009 at 1:49 am

    For transcoding M2TS/MTS to avi, mpeg, etc. I use
    HD Video Converter for Mac
    http://www.talk-mania.com/how/60889-tod-converter-mac-convert-tod-mpg-avi-mp4-wmv-dv-mov-flv-rm-mac-os.html
    This software easily can transcoding these files. I use it for a long time and I haven’t any problem with it.You can try it too.

  102. gogee | August 20th, 2009 at 7:30 pm

    you’re the best man. thx for putting this together

  103. Afchine | September 3rd, 2009 at 12:59 am

    Hi,

    Maybe someone can help me, I bought a new camcorder Canon HG21 and I tried to convert the M2TS files to AVI to be able to watch them on my laptop (OS Windows) but the quality is very poor, the original file size is 29MB and the converted file is only 714KB, the original video size was 1440×1080 and the converted video size is 176×144. Could you please let me know which software I can use for the better quality?
    Cheers,
    Afchine

  104. wenling | September 4th, 2009 at 9:49 pm

    Your original resolution is 1440*1080, and now you converted to 176*144, that’s why you get poor quality.

    Get a iSkysoft video converter, set the output format, and go to setting panel, set the resolution. If you want to convert to SD (Standard-Definition) video, 720*480 should be fine.

  105. johnson | September 22nd, 2009 at 4:53 am

    4Media HD Video Converter you may try, it will convert all general and HD videos to HD AVI, H.264/AVC, HD MPEG4 TS, HD MPEG2 TS, HD WMV, MOD, TOD, AVCHD (M2TS, MTS, M2T), TS, TP, TRP, H.264/AVC, MKV, HD WMV, MPEG-4 and Quick Time etc. HD Quick Time and other general videos and audios. If you want a try, here:
    http://www.flash-video-soft.com/hd-video-converter/

  106. Afchine | September 22nd, 2009 at 10:06 am

    Hi Guys, Thanks for your help, I bought the software WonderShare which is HD video converter and everything is perfect now. Once again thanks for your help.

  107. orfeo | October 4th, 2009 at 11:09 am

    Now you can use “ffmpeg”.

    hdffxvrt is your friend!.

    http://code.google.com/p/hdffxvrt/

  108. Alan | October 9th, 2009 at 1:51 pm

    I have been fairly successful using HandBrake

    http://handbrake.fr

    (Used mostly to create scaled-down, reasonably sized videos that can be easily shared with others.)

  109. Alan | October 9th, 2009 at 1:56 pm

    P.S. Even Mac and Windows users need not be jealous…

  110. roguededguy | November 5th, 2009 at 10:47 am

    VLC plays MTS files natively. I use both ubuntu and Arch with Openbox and the MTS files from my Sony HDR-SR12 play just fine. Actually they play much better than in the SONY provided software for Microshaft and it doesn’t take hours and hours to transfer the files.

    I simply copy them over USB and play them in VLC that’s it.

    If you do want to encode though, Handbrake is the way to go.

  111. Gordon McDowell | November 5th, 2009 at 2:11 pm

    roguededguy, I just want to point out, the MTS files may be slightly corrupt to SONY VEGAS if you then later try to use those MTS files in a project IF they are 2 GB files broken up automatically by the camera.

    I’ve had many 2 GB MTS files that SONY would either not import or not recognize the audio from. Allowing the (kind of annoying) Sony PC software to convert them (rejoin them) to larger M2TS files allowed me to import the same videos without issue.

    So I would recommend letting the import software convert the MTS files to M2TS as you take them off the video camera, in case they cause you grief when you try edit with them later.

  112. Afchine | November 8th, 2009 at 3:35 am

    Hi there, I have a very poor quality when I’m burning the M2TS to the DVD. I’m using the video-to-DVD application from Wondershare software. Do you have any idea?

  113. convert mts | November 26th, 2009 at 11:38 pm

    For Transcoding AVCHD Video MTS/M2TS Into AVI Files with this Software.

  114. MICHAEL WINANS | December 6th, 2009 at 8:15 pm

    Can you give me a link to convert m2ts files?
    Thanks,
    Mike

  115. Alex | December 16th, 2009 at 9:54 pm

    I use WinFF which is GUI frontend for ffmpeg to convert mts files produced by Canon VIXIA HF20 to smaller scale avi’s. For the target format choose AVI and XviD Widescreen preset. The result is perfect.

  116. Ryu | December 19th, 2009 at 11:11 am

    I use this command to compress my m2ts files :

    (4 threads for 4 processors…)

    ffmpeg -i file.MTS -threads 4 -deinterlace -y -vcodec libx264 -sameq -acodec ac3 -ab 192k -ar 48000 -ac 6 -s 1280×720 -r 50 -b 20000k outputfile.avi

    The result is very good! I hope it will be useful…

  117. Tomás | December 29th, 2009 at 1:53 pm

    A little experience with ffmpeg

    ffmpeg -i 24Mps_input.mts -target pal-dvd output_24_dvd.mpg

    It works fine in my Opensuse 11.1. The only problem in my system was that the first version I’ve installed of ffmpeg did not run. It was i686, I replaced it for the i586 package and all it’s ok. Note that i use the pal system. Adjust your settings to ntsc if necessary.
    Sorry for my poor english, I hope at least it’s possible to understand me…
    Happy new year. Great post! Thanks all of you…
    Tom

Leave a Comment