[FFmpeg-user] Problem syncing/lag adaptive bitrate HLS
julien JORDA
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
/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 and I can perfectly play this global playlist with
HTML5 coupled to this flash plugin:
https://github.com/mangui/flashls
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
#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
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?
Thanks!
More information about the ffmpeg-user
mailing list