[FFmpeg-user] HLS adaptive bitrate with ffmpeg is out of sync?
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
- 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
#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 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
the low quality playlist
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?
More information about the ffmpeg-user