In response to my post about ClipWrap, Chris Bevan sent along a note sending me a link to an Apple forum post where somebody has pulled together an Automator application that can rewrap AVCHD files. This script uses an FFmpeg binary that is in ClipGrab, another tool you’d have to download and install to use this script as is. But, you can open it up easily enough and change it to whatever FFmpeg binary you’d like.
Here’s what this script executes for each .mts file it’s given:
$ ffmpeg -i "$1" -acodec copy -vcodec copy "$1.m4v"
Easy enough. I built up a copy of FFmpeg with Homebrew and gave it a spin on some of my Pansonic GH-1 AVCHD clips. On the first go, FFmpeg didn’t want to write an output video file, so I changed the output parameter to use a QuickTime extension:
$ ffmpeg -i movie.mts -acodec copy -vcodec copy movie.mov
The video came through just fine, but the audio didn’t come along for the ride. Searching about, I found a DVXuser discussion thread covering some of the ins and outs of using FFmpeg to rewrap AVCHD. Apparently, while the H.264 stream can be rewrapped without a problem, the AC3 audio track isn’t supported by QuickTime in the MP4 container format. The suggestion there was to transcode the audio to PCM:
$ ffmpeg -i movie.mts -acodec pcm_s16le -vcodec copy movie.mov
That does the trick with the audio. The resulting file plays fine from start to stop, but scrubbing doesn’t work at all. Repositioning the playhead results in the audio tracking just fine, but the video freezes. H.264 isn’t a great format for scrubbing to start with, but in this case the DVXuser discussion thread provides the clue that there’s not a seeking index baked in. The rewrapped video that ClipWrap outputs scrubs acceptably well though, so there’s obviously a solution.
The next step is to find that solution to build up an index. But I haven’t found a solution so far. If you know of one, please let me know and I’ll update this post with the solution (along with credit of course!)