Search code examples
ffmpeghttp-live-streamingtranscoding

Set minimal ts duration in ffmpeg command


We are using ffmpeg to convert mp4 video file to hls. When video is converted, it sometimes happens that last ts chunk is about 0.03s. And player stalls on this chunk for a while. Is there a special command in ffmpeg to set minimal ts duration? Or other way to avoid such ts chunks? In our command to set up ts duration we use: -segment_time 5


Solution

  • One solution is to concatenate chunks. If last ts chunk duration is 0.03s or less we can concatenate it with previous. This will help to avoid last chunk with little duration. To concatenate chunks can be used this ffmpeg command: ffmpeg -i "concat:input1.mpg|input2.mpg|input3.mpg" -c copy output.mpg

    More information here.