[FFmpeg-user] ffmpeg fails to seek after X-EXT-DISCONTINUITY in HLS

Gabriele Greco gabriele.greco at hudl.com
Fri Apr 28 18:08:51 EEST 2023


I tried this with 4.4.x LTS, 5.1 LTS and master and the behaviour is the same, if ffmpeg works with a HLS containing X-EXT-DISCONTINUITY it's not able to add the offset specified in the tag following the discontinuity to the pts to seek correctly, for instance with this video:

https://vf.hudl.com/555131/556589/635/6445905f4356611edaf9f635/f635_thd.m3u8?v=50C4562F3844DB08

that has a discontinuity (just for the pts/dts) every 300 secs, it's impossible to seek past the second 310:

Using:

ffmpeg -ss 310 -i https://vf.hudl.com/555131/556589/635/6445905f4356611edaf9f635/f635_thd.m3u8?v=50C4562F3844DB08 -to 10 -c copy test.mp4

... ffmpeg will choose the right fragment to start decoding, but not finding the required timestamp it will decode the full file and complete with an empty "test.mp4" output.

Checking with ffprobe:


ffprobe -show_frames https://vf.hudl.com/555131/556589/635/6445905f4356611edaf9f635/f635_thd.m3u8?v=50C4562F3844DB08 -select_streams v:0 | grep best_effort_timestamp_time

... it's easy to see that the pts jumps from from 301.44 to 1.48 (the video has a start offset of 1.48):


best_effort_timestamp_time=301.080000
best_effort_timestamp_time=301.120000
best_effort_timestamp_time=301.160000
best_effort_timestamp_time=301.200000
best_effort_timestamp_time=301.240000
best_effort_timestamp_time=301.280000
[https @ 0x7fc444841600] Opening 'https://vf.hudl.com/555131/556589/635/6445905f4356611edaf9f635/9e1f_8000_000_002_0001.ts' for reading
best_effort_timestamp_time=301.320000
best_effort_timestamp_time=301.360000
best_effort_timestamp_time=301.400000
best_effort_timestamp_time=301.440000
best_effort_timestamp_time=1.480000
best_effort_timestamp_time=1.520000
best_effort_timestamp_time=1.560000
best_effort_timestamp_time=1.600000
best_effort_timestamp_time=1.640000

not sure if there is a workaround for this, the m3u8 contains this code:

9e1f_8000_000_000_0070.ts
#EXTINF:4.000000,
9e1f_8000_000_000_0071.ts
#EXTINF:4.000000,
9e1f_8000_000_000_0072.ts
#EXTINF:4.000000,
9e1f_8000_000_000_0073.ts
#EXTINF:4.000000,
9e1f_8000_000_000_0074.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:1970-01-01T00:05:00.000Z
#EXTINF:4.000000,
9e1f_8000_000_001_0000.ts
#EXTINF:4.000000,
9e1f_8000_000_001_0001.ts
#EXTINF:4.000000,
9e1f_8000_000_001_0002.ts


... that should be theoretically enough to add 5 minutes of offset to the timestamp calculation after the discontinuity....

I searched online for a flag or a patch to solve this issue without luck... I found a lot of bugs about EXT-X-DISCONTINUITY and a few patches, but all of them where about different problems that this "terrible" tag creates in ffmpeg...

If there is no solution for this a will build a patch for it, but I want to avoid duplicate work if someone already addressed it and I'm simply not finding the right toggle on ffmpeg or the right patch in the bug tracker to solve it...

Thanks in advance,
 Gabry



More information about the ffmpeg-user mailing list