[FFmpeg-user] Loosing "sync" between HLS streams

Deron deron at pagestream.org
Mon Jan 11 00:29:17 CET 2016


I'm using ffmpeg to generate an HLS stream from a tv tuner capture card, 
and while it generates the sub-streams nicely, it seems that the two 
streams get out of sync pretty quickly for some stations. What I mean by 
that is the segments numbers (and the EXT-X-MEDIA-SEQUENCE) differ. When 
the iPhone decides to switch from one to the other, it will "hang" for 
several seconds before resuming. It seems (hard to reproduce because it 
almost always gets out of sync) shows that it doesn't do that when the 
EXT-X-MEDIA-SEQUENCE is the same between the sub-streams.

The test command is:

ffmpeg -f lavfi -i 
movie=/dev/dvb/adapter3/dvr0:f=mpegts:s=dv+da[out0+subcc][out1] 
-force_key_frames expr:gte(t,n_forced*2) -c:v libx264 -vprofile baseline 
-vf scale=1280:720 -s 1280x720 -aspect 1280:720 -pix_fmt yuv420p -r 30 
-preset veryfast -b:v 1200k -c:a libfaac -ar 48000 -ac 2 -async 2 -af 
volume=volume=11dB -flags:a -global_header -f hls -hls_time 2 
-hls_list_size 10 -hls_wrap 20000 -hls_flags delete_segments 
-hls_segment_filename /var/www/html/stream/wfgc/v.mid.%d.ts -y 
/var/www/html/stream/wfgc/v.mid.m3u8 -force_key_frames 
expr:gte(t,n_forced*2) -c:v libx264 -vprofile baseline -vf scale=640:360 
-s 640x360 -aspect 640:360 -pix_fmt yuv420p -r 30 -preset veryfast -b:v 
200k -c:a libfaac -b:a 50k -ar 24000 -ac 1 -async 2 -af 
volume=volume=11dB -flags:a -global_header -f hls -hls_time 2 
-hls_list_size 10 -hls_wrap 2000 -hls_flags delete_segments 
-hls_segment_filename /var/www/html/stream/wfgc/v.portrait.%d.ts -y 
/var/www/html/stream/wfgc/v.portrait.m3u8

I can provide console output, but I've not seen anything useful after 
piles of output.

I'm guessing that chopping into 2 second segments, then passing to be 
scale/encode in two sub-streams (instead of two sub-streams chopping 
into 2 second segments) would solve the problem but I don't know of any 
way to do that except write an libav* app?

Any suggestions?

Deron


More information about the ffmpeg-user mailing list