[FFmpeg-user] Problem syncing/lag adaptive bitrate HLS
furybubu at gmail.com
Mon Oct 5 19:58:47 CEST 2015
Hi everyone, I am currently having a problem trying to implement adaptive
bitrate of HLS live streams with the help of ffmpeg.
I basically have a RTMP source 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 I am executing:
#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
#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
These two playlist are then combined into a global live playlist as
recommended by Apple.
Everything runs fine and I can perfectly play this global playlist with
HTML5 coupled to this flash plugin:
My problem is when I'm playing this playlist with iOS, every once in a
while the player presents an initial lag before playing normally, or even
displays a black screen with just the sound.
It is worth to notice that the segments in the respective playlists do not
have the same duration:
the high quality playlist
the low quality playlist
When I am playing only the high quality playlist, the playback is perfect.
Does it have to do with a misalignement of the keyframes betwseen the two
playlists and how can I fix that?
More information about the ffmpeg-user