Saturday, December 10, 2011

AVCHD in Avidemux

AVCHD is a HD movie format that is present on many consumer cameras, most notably on Panasonic TZ (SZ in America) compact series. Searching for a decent replacement for VirtualDub (Swiss army knife for video editing) for Windows I came across Avidemux. It is a nice tool but still in development stage so it has some problems with editing AVCHD movies - for example, trying to save a part of a AVCHD movie into MPEG4 format without recording (video copy, audio copy) produces corrupt movies with either sound not working or not synchronized with picture etc. But there is a solution or at least a workaround for it: replace the AVCHD container* with MPEG4v2 and the editing works as it should.

In this step FFmpeg utility comes handy - with a simple script, similar to the one mentioned in the "Batch convert MP3 bitrate on Windows using lame MP3 encoder" post we can change the container:


forfiles /m *.mts /c "cmd /c ffmpeg.exe -i @file -acodec copy -vcodec copy @file.mp4"

But be sure to have enough free disk space before starting the process. :) After the conversion you have the choice: delete the AVCHD (*.MTS) files and keep the new MPEG4 files for archiving purposes or vice versa. But be aware: FFmpeg does not support the hdmv_pgs_subtitle data stream (GPS information embedded in the video) so this information could be lost with the conversion.

*What is a container (or mux/demux)? It is a "receipt" how video and audio stream(s) are saved inside a file. So by changing the container the video and audio streams get somehow reordered inside the file but the actual content of a streams do not change. There is no recoding involved, just pure copying from source to destination file. This is a quite important because:
  1. It is fast.
  2. There is no loss in quality.