Bug 508947

Summary: Import of sequences of .ts files: cumbersome and audio gaps
Product: [Applications] kdenlive Reporter: Uwe Dippel <udippel>
Component: Project Bin & ImportAssignee: Jean-Baptiste Mardelle <jb>
Status: REPORTED ---    
Severity: minor    
Priority: NOR    
Version First Reported In: 25.08.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: kdenlive rendered output .ts added one by one to timeline
kdenlive rendered output .ts merged with cat before import

Description Uwe Dippel 2025-08-30 17:42:14 UTC
SUMMARY
Importing a file cut up to sequences of .ts clips is cumbersome, and not error free. It is possible to import a sequence of images, though I haven't found an import of a sequence of video clips.
Therefore I do it one by one, dragging them one by one to the timeline. Already there, most often some audio gap is audible, in the project monitor as well as in the final product.
This is not principally a problem of kdenlive, but a concatenation problem, observed by several sources; well before kdenlive comes into perspective, e.g.
https://superuser.com/questions/692990/use-ffmpeg-copy-codec-to-combine-ts-files-into-a-single-mp4
The reference given there states something wrong:
https://trac.ffmpeg.org/wiki/Concatenate
, that's also what Google (AI) suggested. Firstly, the gaps remain, and mostly, the output is just a 48 kHz stereo of the first channel, with `ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy output.ts`

STEPS TO REPRODUCE
1. "Add Clip" for multiple .ts sequences
2. Drag one after the other to the timeline
3. Listen to audio at transition points, in the timeline as well as final rendered product

OBSERVED RESULT
Import is cumbersome
At transitions of .ts clips, some more or less audible audio gaps appear

EXPECTED RESULT
Simple import of multiple, subsequent .ts clips
Handling audio transitions properly

ADDITIONAL INFORMATION
There are sources stating that - instead of ffmpeg - a simple `cat` would do the trick. But then, the audio could fall out of sync. 
https://www.linuxquestions.org/questions/linux-software-2/media-newbie-how-do-i-stitch-together-multiple-ts-files-into-a-single-video-4175491445/
and
https://stackoverflow.com/questions/33599831/concatenate-ts-files-with-correct-timestamps

(I was wondering if I should split this into two items; the major one for me is the audio gaps, of course, for which I didn't find ANY solution. However, I decided to put both into this posting, since the gaps only appear at merge points of imported .ts files in time, on the timeline.)
Comment 1 Uwe Dippel 2025-08-31 10:54:52 UTC
In the meantime, I had an exchange on this with the ffmpeg mailing list.
It turns out, that the command given  on 
https://trac.ffmpeg.org/wiki/Concatenate
is incomplete/wrong. It should be 
ffmpeg -f data -i "concat:input1.ts|input2.ts|input3.ts" -map 0 -c copy -f data output.ts
which serves the purpose, at least with respect to cover all streams.
Funnily enough, though, the resulting file here is identical (md5sum) to the output of 
cat *.ts >> output.ts

If this could be confirmed (it does astonish me), the import of .ts sequences (almost always found when recording satellite or cable) would be much simplified.
Comment 2 Uwe Dippel 2025-08-31 12:03:31 UTC
Created attachment 184604 [details]
kdenlive rendered output .ts added one by one to timeline
Comment 3 Uwe Dippel 2025-08-31 12:04:39 UTC
Created attachment 184605 [details]
kdenlive rendered output .ts merged with cat before import
Comment 4 Uwe Dippel 2025-08-31 12:18:52 UTC
Had the time to render one set of .ts files in two trials. One - as always done in the past, one by one added one after the other onto the timeline -, and one with cat *.ts >> output.ts before importing the single output.ts.
And the gap is gone! (Wished I had dived into this earlier, because over the years, all my rendered files tend to have short gaps at the merge points of the .ts files on the timeline.)

Those gaps seem identical among the (wrongly) concatenated files by the command given on the ffmpeg wiki, and those that are found in the rendered output of kdenlive. (Does kdenlive use a similar concatenation method as given on the wiki?)
Since I rendered some 80+ files with kdenlive during the last years, and all have these gaps, more or less audible/visible, it is a pity I deleted the originals, so that I can't redo those results. But I don't complain!

I suggest to handle this as a bug, however, from here onwards, because dumping recording results of .ts sequences separately on the timeline is supposed to work without artefacts, especially since a proper concatenation in advance of the import can produce a properly rendered output.