iMovie and MTS

A few times before I have imported my short clips from the Sony HDR-CX106 camcoder directly using iMovie camera import features. Now, that I had a bit longer videos on the camera, I got to thinking why it takes so long and how come it reports that 60 GB of my hard drive will fit only 1 hour or so full-quality video. It turns out that by importing, iMovie probably converts all the clips into HDV compliant format, thus MPEG2 and thus resulting in wasting my hard drive space.

What about AVCHD?

This was the question I asked myself and by googling around I found out that as of yet, iMovie does not directly support AVCHD format. But it does not have any problems with the H.264 encoded videostream in the file nor with AC-3 encoded audio stream.So – obvious solution was to repackage the file into another format using FFmpeg.

First up was ofcourse MP4, but as it turns out, AC-3 audio is not officially supported and iMovie refuses to import such a file. So I installed also libfaac to encode AAC, which is MP4’s default audio encoding and run:

ffmpeg -i 0001.MTS -vcodec copy -acodec libfaac -ar 48000 -ac 2 -ab 320k 0001.mp4

Unfortunately this method was a bit slow, as it reencodes the whole audio stream, so as I was not limited to MP4 format and iMovie is more than happy with MOV files, I could instead just copy both streams into a MOV container:

ffmpeg -i 0001.MTS -vcodec copy -acodec copy

Now I can just drag these files to iMovie and only have to wait for it to update thumbnails. And most important – disk usage is kept normal, not increased tenfold as with direct import.

Automated batch conversion

The above command can be turned into a script that takes output folder as argument and list of files as input:

#!/usr/bin/env sh

#  Created by Laas Toom on 17.03.10.
#  Copyright (c) 2010 Laas Toom, All Rights Reserved.

if [[ -z "$ffmpeg_bin" ]]; then ffmpeg_bin=$(which ffmpeg); fi
if [[ -z "$growl" ]]; then growl=$(which growlnotify); fi
if [[ -z "$vcodec" ]]; then vcodec="copy"; fi
if [[ -z "$acodec" ]]; then acodec="copy"; fi
if [[ -z "$ofmt" ]]; then ofmt="mov"; fi
if [[ -z "$output_dir" ]]; then output_dir=~/Desktop;  fi

while read movie
  if [[ -f "$movie" ]]
    base=$(basename "$movie")
    $growl -H localhost --image "$mypath/ffmpeg.png" -s -d "$base" -m "mts2mov: Transcoding: $movie ..."
    ls -la "$movie"
    # somehow ffmpeg steals the input of this shell and so we have to fake input to ffmpeg
    echo "" | $ffmpeg_bin -i "$movie" -vcodec $vcodec -acodec $acodec "$ofile"
    test -f $growl && $growl -H localhost --image "$mypath/ffmpeg.png" -d "$base" -m "mts2mov: Transcoding: $movie ... Done"
    echo "$ofile"
test -f $growl && $growl -H localhost --image "$mypath/ffmpeg.png" -m "mts2mov: All Done"

NOTE: the script is written on a Mac and uses Growl to give feedback. If you don’t want/have them, just comment out all lines with growlnotify in them and you should be OK.

Automator service

I turned the above script into an Automator Action and that action in turn into a Finder Service, so that I can use it conveniently from the finder window.

Bot of them can be found at my Automator page.

8 thoughts on “iMovie and MTS

  1. Hi,

    First of all thanks for sharing this helpful info. I might be on the right track but I still have som issues when doing the conversion.

    My output video doesn’t play any sound, even if MediaInfo sais it does have a AC3 sound stream. Also even if the frame rate looks right I get some really strange color flickering effects (like colors from one tone to another every second). I tried to play this both with VLC and Quicktime and I get the same problem. If it just copies the video stream, shouldn’t it just play the same regardless of container?

    May I ask if you get a clean copy of the source or do you see any differences in color or frame rate? Does ffmpeg output any warnings att all when you do this?

    My source camera is a Panasonic Lumix DMC-TS1S and I do the conversion with latest stable of FFmpeg on Linux….

    Thanks for you time 🙂


    • Hi Swex,

      I get my video and audio correctly w/o any flickering. Have you tested these files on different computer (preferably different OS)?
      Maybe something has gone awry with the decoding libs.

      Does VLC play the original file before converting?

      And did you notice that MP4 standard does not specify AC-3 as an allowed audio stream. You have to reencode it to e.g. AAC.



  2. I think this is probably something unique to Lumix cameras. I also have the same color flickering problem. I tried first going both mp4 (reencoding audio) and I saw the color flicker. When I just copied both stream into the .mov, the same color flickr was there. However, I used Handbrake to re-encode both audio/video and the result is perfect.

    Would you mind taking a look at one of my .mts file to see what is so special about it?


    • Hi Min,

      I certainly can have a look, though I do not call myself an expert in this regard.
      If you upload your files somewhere, mail me a link. (Contacts can be found above).


  3. Hiya Laas, I have been trying to use your automator action in my workflow, but I keep getting the “Check the actionʼs properties and try again” error.

    I know that ffmpeg has been installed properly, because I can still use
    “ffmpeg -i 0001.MTS -vcodec copy -acodec copy”
    from the terminal and it converts just fine.

    any advice?

    workflow screenshot:


    • Hi Matthew,

      Maybe the workflow can not find ffmpeg on the PATH. Maybe you could specify the full binary path in the override field?

      If this does not help, I can look more into it.



  4. Fantastic – thanks. Can I suggest that you add some more search engine terms in your blog post and title as it took ages to find this until I included ffmpeg in my mts to mov search.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s