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

Deron deron at pagestream.org
Sat Feb 13 17:20:49 CET 2016

On 1/10/16 4:29 PM, Deron wrote:
> 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.
> 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

No replies, so maybe I can ask a more specific question that someone has 
an answer for.

Right now, I presume the above command does something like this (and 
that force_key_frames is for some reason choosing different places 
between the two process paths)

input stream --->  [force_key_frames] [scale] etc [segment] -> output1
              |-->  [force_key_frames] [scale] etc [segment] -> output2

Is there some way to cause this instead:

input stream [force_key_frames] ---> [scale] etc [segment] -> output1
                                 |--> [scale] etc [segment] -> output2

Or better yet:

input stream [force_key_frames] [segment] ---> [scale] etc -> output1
                                           |--> [scale] etc -> output2




Happy Trails,
Deron Kazmaier   deron at dogstarkennel.com
KD0AYO	Western South Dakota
Dog Star Kennel http://www.dogstarkennel.com
--- Racing AKC Sepp-Star Seppala Siberian Husky Sled Dogs

More information about the ffmpeg-user mailing list