[FFmpeg-user] why doesn't fast seeking work in live hls

Louis Letourneau lletourn49 at gmail.com
Tue May 23 22:33:15 EEST 2017


As a follow up, if anyone wants to enable and use fast (index) seeking
in HLS videos while they are being transcoded, the secret is to use
the

-hls_playlist_type event

parameter as mentioned in the doc here:
https://ffmpeg.org/ffmpeg-all.html#toc-Options-38

This feature was added decembre 2015 so it's been in the 3.2 branch
for awhile now.

Louis

On Fri, May 19, 2017 at 5:49 PM, Louis Letourneau <lletourn49 at gmail.com> wrote:
> Just a question before I start diving in the code, why doesn't fast
> seeking work on live hls feeds/streams/files?
>
> Context:
> If you create a dummy video:
> mkdir -p a;ffmpeg -y -s 640x480 -f rawvideo -pix_fmt rgb24 -r 25 -i
> /dev/zero -vf "drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeMono.ttf:
> text=%{n}: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1:
> boxcolor=0x000000FF" -an -vcodec libx264 -preset medium -tune
> stillimage -crf 24 -pix_fmt yuv420p -shortest -force_key_frames
> "expr:gte(t,n_forced*5)" -bf 0 -hls_time 5 -hls_list_size 0 -hls_wrap
> 0 -hls_allow_cache 1 -hls_segment_filename "a/a_%04d.ts" -t 9999
> a/a.m3u8
>
> let it encode
> and in another terminal try to seek (once the encoding passed the time
> you want to seek to)
>
> ffmpeg -v info -ss 00:00:10 -y -live_start_index 0 -i a/a.m3u8 -f
> image2 -vframes 1 a.png ; feh a.png
>
> You'll get in the logs
> a/a.m3u8: could not seek to position 11.400
>
> and then ffmpeg will decode all frames until the asked frame.
>
> If you quit the encoder and seek again, it fast seeks immediately
> (jumps to the right segment and decodes te right frame). It doesn't
> need to fo through all the segments.
>
> My question is, if the segments (.ts) are already there and the
> manifest, m3u8 already shows that they are there, why doesn't fast
> seeking work?
>
> Thanks
> Louis


More information about the ffmpeg-user mailing list