Unsynchronized Audio and Video using Panasonic DMC-TZ7/ZS3 AVCHD and FFmpeg
 
Support Ukraine

Unsynchronized Audio and Video using Panasonic DMC-TZ7/ZS3 AVCHD and FFmpeg

When converting video shot with a Panasonic DMC-TZ7/ZS3 in AVCHD mode from MTS to AVI using FFmpeg and the copy codecs, the video is delayed by 2.6 seconds. This can be avoided by first splitting audio and video and then reassembling the two tracks.

The naive way of doing a conversion from MTS to AVI is:

ffmpeg -i 00000.MTS -vcodec copy -acodec copy -f avi 00000.avi

This will cause the video to be delayed 2.6 seconds (65 frames) relative to the audio track. This manifests itself as the first 2.6 seconds being sound but no image, and the last 2.6 seconds being image without sound. The only way I've managed to get the conversion to work as expected is:

ffmpeg -i 00000.MTS -vcodec copy 00000.h264
ffmpeg -i 00000.MTS -acodec copy 00000.ac3
ffmpeg -i 00000.ac3 -i 00000.h264 -vcodec copy -acodec copy -f avi 00000.avi

That is, first extract audio and video to separate files, and then remux them. (I tried to use the -map option but couldn't get it to work.) Once the remuxing is done the .ac3 and .h264 files can be deleted.