Sound gap on stitching together splitted AVCHD files

Hello everybody! :slight_smile:

I have non-stop recorded ~43 min video in AVCHD format. Camcorder (Sony NEX-EA50) splitted .MTS files every 2.1GB (about 11min48sec each). Importing all the .MTS files from STREAM folder and adding them to the timeline file by file or selecting all .MTS files and grabbing them to the timeline ends with tiny sound gaps on the stitching points, while the video is smooth. The problem persists both in preview and in the exported file.

Two questions:

  1. Is there any correct way to add AVCHD materials to the playlist / timeline? Maybe just grabbing .MTS files to the playlist / timeline isn’t correct way to handle this video format?
  2. In some other forum I found that stitching splitted files in program like File Joiner solves the problem. But this program is for Windows, while I use Linux… Using ffmpeg ‘concat’ option somehow reencodes original PCM sound to MP2 (mpga) 384kbps, even if I define ‘copy’ in audio codec CLI string. Maybe somebody knows Linux alternative to ‘File Joiner’ program?

I use Shotcut 21.10.31 on Linux Mint Xfce 20.2 Uma.

Do the source files actually have WAV/PCM audio in them, as opposed to AAC/AC-3?

If it were AAC, I would understand since it has codec startup delay.

Hi, Austin. Thank You for Your reply.

No, the AVCHD has H.264 with LPCM sound…

You can try removing a frame or two from the end of each part and see if the video is still smooth enough. Sometimes a frame is repeated at the end because the audio stream is a little longer than the video, but that extra bit of audio is not the duration of a video frame in which Shotcut engine operates. You can also try a cross transition of one or two frames to conceal any abrupt audio change.

Linking to this thread because it is related. But it does not really answer your question since it still suggests Windows tools:

What if you define the codec to be some other lossless audio format? Converting from PCM to lossless audio should not be a problem.

1 Like

Hi, brian! On the linked thread not only Win-tools, but also:

Thank You a lot a lot! It looks like that this simple concatenating tool does it - it creates one big file from the truncated ones, and the big one includes all the streams in the original quality both of video and of sound. Actually, the workflow for these kinds of splitted files of AVCHD that have to be concatenated is just to locate all consequent .MTS files with 2GB size and the next smaller one and to join them to one file - it will prevent the sound gaps on the joint points.

I think that the problem is in the demuxer, isn’t it? Looks like those kinds of recording formats (with splitted files) are obsolete, but are still very popular. Do You think there is any chance to get some kind of fix?

I tried some lossless formats, like pcm_s16le, pcm_bluray, but ff still made for me MTS with MP2… Looks like the .MTS in the output file’s name extension sets the codecs in the way that ff ‘thinks’ that are standard for the output file format. 'Cause changing the output file’s name extension to .mp4 recoded the sound to AAC (or AC3, don’t remember already…) Maybe I was doing something wrong on ff CLI syntax, or maybe just kind of bug…

Thank You for Your answer!
But the problem is that if I do so, I will harm either the video smoothness or there will be some gap in the sound…
And I need to keep whole video without any allusion of editing - no cuts in video, no cuts in audio…

The demuxer is abstracted two layers deeper than Shotcut: MLT and then FFMpeg. Shotcut relies on the frame selection logic in MLT which in turn relies on the seeking accuracy of FFMpeg. MTS files are inherently difficult to seek due to the codec packetization method it uses.

MTS is a good format for real-time recording and streaming - which is why it is still in use today. It is just not great for offline frame accurate seeking and editing.

Because of the software architecture and the inherent difficulty of MTS files, I think it is unlikely that we will have a fix.

In general, for MTS files, people commonly complain about slowness and poor seeking for those file types. A common “solution” is to convert the files to “Edit Friendly” before editing.

This topic was automatically closed after 90 days. New replies are no longer allowed.