Search code examples
videoffmpeghttp-live-streamingtranscoding

FFmpeg concat command changes start_time (ts chunks concatenation)


I concatenate ts chunks using ffmpeg command: ffmpeg -i "concat:input1.ts|input2.ts" -c copy output.ts

For example video consists of 10 ts chunks, and we concatenate only two last chunks (ninth and tenth ts chunks). And we stream video consisting of old (1-8) ts chunks and new joint ts chunk. There is a problem with playback of result joint chunk. After investigation we found that in joint ts chunk some properties are differ:

start_pts=127141
start_time=1.412678

Although in original (ninth) ts chunk they are:

start_pts=2021483
start_time=21.213400

Start time and start_pts were changed, we suppose that playback issue is related to this properties in ts chunk.

Is there a way to leave the old values (start_pts and start_time) for result joint ts chunk?


Solution

  • Use

    ffmpeg -copyts -i "concat:in1.ts|in2.ts" -muxpreload 0 -muxdelay 0 -c copy joint.ts
    

    You need -copyts to preserve input timestamps till the muxer stage. And the two mux output options set to 0 to prevent further TS modifications by the MPEG-TS muxer.