4

I've gone through several different variants of this process and it always causes me problems. I've gotten it working sometimes but it doesn't seem to be consistent.

I have a video camera which records AVCHD to MTS files, it splits files at 3.89GB. Since its microphone is crap, I also record audio separately and have to sync them back up before editing. The problem I have is that the audio recorder doesn't break files at the same times so I'll usually end up with 3 video files and 1 audio file.

So I'm wondering where things are going wrong in this process:

  1. Converted all the H264 MTS files to ProRes MOV files. The editor handles ProRes better than the compressed files so I convert. ffmpeg -i 00000.MTS -vf "yadif=3:-1:1,mcdeint" -vcodec prores -vprofile 2 -ar 48000 1.mov
  2. Concatenated the 3 .mov files together. At this point I have a file with video stutters every ~32 minutes, but the audio stays in sync with the video. ffmpeg -f concat -i mylist.txt -c copy full.mov
  3. Extracted the audio to FLAC. Imported into audacity, lined up the external audio with a clap and trimmed to length. At this point both audio tracks line up, the external track is still in sync with the camera audio at the end. Export the new external audio matched to the start and the length of the original audio. ffmpeg -i full.mov -aq 256k full.flac
  4. Recombine the large .mov file with the new audio. At this point the audio that was just in sync with the original audio from the video files now goes out of sync when the video stutters. ffmpeg -i full.mov -i full-tascam.flac -map 0:0 -map 1 -vcodec copy -ar 48000 full-tascam.mov

What do? I've had the same problem before introducing ProRes, just concatenating the MTS files into MP4 copying the video stream and adding the new audio. Is there anything I can set while concatenating to remove the stutters, or to prevent them from throwing the new audio out of sync when I'm adding that track?

1
  • 1
    It sounds like camera is giving each successive .MTS file a little bit of a handle, or it's dropping a couple frames between segments. Do an experiment: point the camera at some running timecode on a TV and let it record a few segments, and see if there's an overlap in the timecodes, or if numbers are getting dropped.
    – iluvcapra
    Aug 13, 2015 at 1:41

1 Answer 1

1

For some reason I think this is avoided when using ffmpeg's concat PROTOCOL (ffmpeg -i "concat:...") rather than its concat DEMUXER (ffmpeg -f concat -i mylist.txt). Oddly, it's also slightly more convenient since using the demuxer requires me to create the text file with the file names in it while with the protocol I can just specify them on the command line, eg: ffmpeg -i "concat:00001.MTS|00002.MTS|00003.MTS" -c copy output.mts

I'll need to confirm this later, I'm at the wrong computer but something brought the question to my attention so I decided to update it with new information.

1
  • To concatenate mp4 losslessly you use these steps: ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts´, then ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts` and finally: ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4.
    – Adriano P
    Jan 24, 2017 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.