[FFmpeg-user] HLS adaptive bitrate with ffmpeg is out of sync?
julien JORDA
furybubu at gmail.com
Mon Oct 12 06:00:15 CEST 2015
Hi everyone, I have a problem when generating an adaptive bitrate playlist
in HLS with ffmpeg.
I basically have a RTMP input stream that I'm converting into two HLS
playlists:
- One is just demuxing and segmenting the video into ts files,
- A second of lower quality with audio only, in this case I use the
libfaac codec to compress it.
Here is what how I generate those two:
#the high quality
ffmpeg -i rtmp://localhost/live/$name -bsf:v h264_mp4toannexb -c:a copy
-c:v copy -sc_threshold 0 -hls_time 5 -hls_list_size 3
-hls_segment_filename '/live/$name_hi/%d.ts' -hls_allow_cache 0
/live/$name_hi/index.m3u8
#the low quality
ffmpeg -i rtmp://localhost/live/$name -async 1 -vsync 1 -ab 55k -bufsize
55k -vn -c:a libfaac -sc_threshold 0 -hls_time 5 -hls_list_size 3
-hls_segment_filename '/live/$name_low/%d.ts' -hls_allow_cache 0
/live/$name_low/index.m3u8
These two playlist are then combined into a global live playlist as
recommended by Apple.
Everything runs fine if I play it on a browser, but with iOS devices there
is most of the time an initial lag before playing normally, or sometimes
only a black screen with sound.
Most likely the problem comes from the fact that the segments in the low
and high quality playlists do not have the same duration:
the high quality playlist
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:7
#EXTINF:4.000000,
7.ts
#EXTINF:6.000000,
8.ts
#EXTINF:4.000000,
9.ts
the low quality playlist
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:7
#EXTINF:4.992300,
7.ts
#EXTINF:4.992289,
8.ts
#EXTINF:5.015511,
9.ts
It is to note that when I am playing only the high quality playlist, the
playback is perfect.
Is my problem due to a misalignement of the keyframes betwseen the two
playlists and how can I fix that?
Thanks!
More information about the ffmpeg-user
mailing list