videoffmpeghttp-live-streamingfmp4

How do you convert fragmented MP4 to MP4 with ffmpeg and keep all fragments?


I am trying to convert a fragmented MP4 (fMP4) to a single MP4 file using ffmpeg. I expected the following command to work, but it only results in the initialization segment and the last three segments being processed by ffmpeg. I am using version 6.1.1 of ffmpeg.

ffmpeg -i playlist.m3u8 -c copy complete.mp4

The content of the playlist is as follows.

#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:EVENT
#EXT-X-MAP:URI="segment_00000.mp4"
#EXTINF:0.525000,
segment_00001.m4s
#EXTINF:2.000000,
segment_00002.m4s
#EXTINF:1.933333,
segment_00003.m4s
#EXTINF:2.001667,
segment_00004.m4s
#EXTINF:2.000000,
segment_00005.m4s
#EXTINF:2.000000,
segment_00006.m4s
#EXTINF:2.000000,
segment_00007.m4s
#EXTINF:2.000000,
segment_00008.m4s
#EXTINF:2.000000,
segment_00009.m4s
#EXTINF:2.000000,
segment_00010.m4s

The output from the command shows which segments are processed, and it is skipping all but the three last segments. The results are the same if I try other playlists with more or less segments. It is always init + the last three.

[hls @ 0x7f497b312600] Opening 'segment_00000.mp4' for reading
[hls @ 0x7f497b312600] Opening 'segment_00008.m4s' for reading
[hls @ 0x7f497b312600] Opening 'segment_00009.m4s' for reading
[hls @ 0x7f497b312600] Opening 'segment_00010.m4s' for reading

Is there anything I can do to force ffmpeg to process all the referenced files in the playlist?


Solution

  • Use ffmpeg -live_start_index 0 -i playlist.m3u8 -c copy complete.mp4