So I've got .m3u8 file which looks like this:
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:6.006,
seg-1-v1-a1.ts
#EXTINF:4.004,
seg-2-v1-a1.ts
#EXTINF:10.010,
eg-3-v1-a1.ts
#EXTINF:10.010,
seg-4-v1-a1.ts
#EXTINF:10.010,
seg-5-v1-a1.ts
#EXT-X-ENDLIST
and I've got all the segment files in one folder.
The problem is that "seg-4-v1-a1.ts" is broken (only 5 MB where it should be 10MB) and when I try to transform them to an mp4 with the command ffmpeg -i "M3U8URLS.mux" -c copy output.mp4
, I get a bad sync of the audio and the video.
The output of ffmpeg is
[hls,applehttp @ 000002e276a868a0] Opening 'crypto:seg-1-v1-a1.ts' for reading
[hls,applehttp @ 000002e276a868a0] Opening 'crypto:seg-2-v1-a1.ts' for reading
[hls,applehttp @ 000002e276a868a0] Opening 'crypto:seg-3-v1-a1.ts' for reading
[hls,applehttp @ 000002e276a868a0] Opening 'crypto:seg-4-v1-a1.ts' for reading
[mpegts @ 00000204393ed020] PES packet size mismatch
[hls,applehttp @ 000002e276a868a0] Opening 'crypto:seg-5-v1-a1.ts' for reading
frame=35130 fps=1927 q=-1.0 Lsize= 1017088kB time=00:00:40.12 bitrate=5667.5kbits/s speed=80.6x
How can I tell ffmpeg that it should stay synced based on the #EXTINF info?
You must modify the playlist and set a #EXT-X-DISCONTINUITY after the broken file.