<p>For some reason I think this is avoided when using ffmpeg's concat PROTOCOL (<em>ffmpeg -i "concat:..."</em>) rather than its concat DEMUXER (<em>ffmpeg -f concat -i mylist.txt</em>).  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: <em>ffmpeg -i "concat:00001.MTS|00002.MTS|00003.MTS" -c copy output.mts</em></p>

<p>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.</p>

CC BY-SA 3.0
2017-01-24T04:44:48.427Z
To concatenate mp4 losslessly you use [these steps](https://trac.ffmpeg.org/wiki/Concatenate#protocol): `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
CC BY-SA 4.0
2024-04-07T19:12:40.630Z
This worked for me. The video using the concat protocol was about 1.78% shorter than the one using the concat demuxer. No lag in the former.
Tushar Rakheja
CC BY-SA 3.0
2015-11-03T14:21:33.330Z
2015-11-03T14:21:33.330Z
Sloloem
<p>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.</p>

<p>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.</p>

<p>So I'm wondering where things are going wrong in this process:</p>

<ol>
<li>Converted all the H264 MTS files to ProRes MOV files.  The editor handles ProRes better than the compressed files so I convert. <em>ffmpeg -i 00000.MTS -vf "yadif=3:-1:1,mcdeint" -vcodec prores -vprofile 2 -ar 48000 1.mov</em></li>
<li>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. <em>ffmpeg -f concat -i mylist.txt -c copy full.mov</em></li>
<li>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. <em>ffmpeg -i full.mov -aq 256k full.flac</em></li>
<li>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. <em>ffmpeg -i full.mov -i full-tascam.flac -map 0:0 -map 1 -vcodec copy -ar 48000 full-tascam.mov</em>  </li>
</ol>

<p>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?</p>

CC BY-SA 3.0
2015-08-13T01:41:19.260Z
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
<ffmpeg><codec><sync><prores>
ffmpeg concatenation introduces video stutter but does not affect audio
Sloloem
# ffmpeg concatenation introduces video stutter but does not affect audio

(Asked by: username_0 on 2015-08-11)

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?

**Tags:** ffmpeg, codec, sync, prores

> **Comments:**
> **username_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.  

---

## 1 answers

### Answer by username_0 on 2015-11-03. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_2**: To concatenate mp4 losslessly you use [these steps](https://trac.ffmpeg.org/wiki/Concatenate#protocol): `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`.  
> **username_3**: This worked for me. The video using the concat protocol was about 1.78% shorter than the one using the concat demuxer. No lag in the former.  

---

