
On FFmpeg version 4.2.2 and later, I can create clips so long as they end before the second-to-last TS file. On FFmpeg versions 4.2.1 and earlier, it starts by downloading the TS file containing my clip segment, then proceeds to download every TS file in the M3U8 then hangs while waiting for new TS files to become available, downloading them as they appear - even hours after the end of the section I wanted to clip. When the M3U8 URL provided is a live stream (no #EXT-X-ENDLIST tag) then FFmpeg does not behave correctly. Also in theory I can force -accurate_seeking to discard the contents from 4:51 to 5:00 and start the clip where I wanted it, but I learned this only works for transcodes and not transmux In theory I can utilize -to instead of -t to specify an ending time of 5:30, however in practice this hasn't worked.

The -t parameter sets an exact clip duration instead of an ending position, so in the above example of a clip starting at 4:51 the same clip would end at 5:21 instead of 5:30.TS file boundaries function as "seek points" in HLS, so if a TS file starts at 4:51 and the next TS file starts at 5:01, this command will start the clip at 4:51 instead of 5:01 (it prefers the first seek point before the requested time).By putting -ss before -i FFmpeg uses "seek points", which with HLS videos means it looks at the M3U8 and only downloads relevant TS files

If -ss comes after -i then FFmpeg will attempt to download the entire M3U8 instead of just the relevant TS files, and will parse the entire video contents looking for the exact timestamp.The command looks like this: ffmpeg -ss -i -c:v copy -c:a copy -t -f mp4 -y out.mp4įor example, to create a 30-second clip starting at the 5-minute mark for a particular video, the command would be: ffmpeg -ss 300 -i -c:v copy -c:a copy -t 30 -f mp4 -y out.mp4

I'm using FFmpeg to generate video clips from M3U8 videos.
