HTTP Live Streaming multiple quality output

About encoding, codec settings, muxers and filter usage
VinDuv
New Cone
New Cone
Posts: 1
Joined: 03 Jun 2012 23:24

HTTP Live Streaming multiple quality output

Postby VinDuv » 06 Dec 2012 21:47

Hello everyone,

I’m using VLC to stream/convert a video file to a bunch of formats. The sout option I use looks like this:

Code: Select all

#duplicate{ dst="transcode{ vcodec=h264,venc=x264{ultrafast},acodec=s16l,threads=6 }:std{ access=file,mux=mkv,dst=… }", dst="transcode{ fps=24,vcodec=theo,vb=800,width=720,height=405,threads=2,acodec=vorb,ab=128,channels=2 }:duplicate{ dst=std{access=file,mux=ogg,dst=…}, dst=std{access=shout,mux=ogg,dst=source:…} }", dst="transcode{ fps=24,vcodec=theo,vb=600,width=320,height=180,threads=2,acodec=vorb,ab=128,channels=2 }:std{ access=shout,mux=ogg,dst=source:… }", dst="transcode{ fps=24,vcodec=h264,vb=1000,width=854,height=480, venc=x264{aud,profile=baseline,level=30,keyint=30,ref=1},acodec=mp3,ab=96 }:std{ access=livehttp{seglen=10,delsegs=true,numsegs=5,index=…/live_hd.m3u8,index-url=…/live_hd_########.ts}, mux=ts{use-key-frames},dst=…/live_hd_########.ts}' }", dst="transcode{ fps=24,vcodec=h264,vb=600,width=640,height=360, venc=x264{aud,profile=baseline,level=30,keyint=30,ref=1},acodec=mp3,ab=96 }:std{ access=livehttp{seglen=10,delsegs=true,numsegs=5,index=…/live_sd.m3u8,index-url=…/live_sd_########.ts}, mux=ts{use-key-frames},dst=…/live_sd_########.ts}' }" }
The MKV/x264 and the two Ogg Theora streams work well. The two HTTP Live Streaming outputs also work well individually, but I am unable to combine them into a multiple quality HLS stream. I use the following m3u8 file:

Code: Select all

#EXTM3U #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=900000,RESOLUTION=640x360 live_sd.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1500000,RESOLUTION=854x480 live_hd.m3u8
With video players able to switch between the two streams (like VLC), problems occur. For instance, VLC loads two live_sd segments, and then continues with live_hd segments. When the switchover occur, the video freezes.

I have looked at the individual video segments, and I noticed that they do not seem properly synchronized (e.g. live_sd_00000010.ts and live_hd_00000010.ts are not exactly the same part of the original video). This is also visible in the VLC console output: the two livehttp access modules report which segments they just wrote, and after some time their respective messages are not simultaneous.

Is there a way to get two properly synchronized HLS streams?

Thanks.

ibstars
Blank Cone
Blank Cone
Posts: 42
Joined: 20 Feb 2009 21:57
VLC version: Mul-versions
Operating System: Windows
Location: The richest man in Babylon

Re: HTTP Live Streaming multiple quality output

Postby ibstars » 07 Dec 2012 00:26

You can try these examples. Quality Broadcast X264

Recommended res
#transcode{ab=64, vb=300, height=240, width=320, threads=2, acodec=mp3, channels=2, venc=x264{ref=2, subme=4}, vcodec=h264}:duplicate{dst=standard{access=http, mux=asf, dst=127.0.0.1:1234}}

Live event HD
#transcode{vfilter={adjust{saturation=1.2}}, ab=96, vb=1000, height=544, width=960, threads=2, acodec=mp3, channels=2, venc=x264{deblock=1:-1, ref=2, subme=4}, vcodec=h264}:duplicate{dst=standard{access=http, mux=asf, dst=127.0.0.1:1234}}

Live event SD
#transcode{vfilter={adjust{saturation=1.1}}, ab=64, vb=400, height=320, width=480, threads=2, acodec=mp3, channels=2, venc=x264{deblock=-1:1, ref=2, subme=4}, vcodec=h264}:duplicate{dst=standard{access=http, mux=asf, dst=127.0.0.1:1234}}

Animation
#transcode{vfilter={adjust{}}, ab=64, vb=500, height=480, width=640, threads=2, acodec=mp3, channels=2, venc=x264{deblock=2:2, ref=2, subme=4}, vcodec=h264}:duplicate{dst=standard{access=http, mux=asf, dst=127.0.0.1:1234}}

Music
#transcode{vfilter={adjust{}}, ab=128, vb=300, height=240, width=320, threads=2, acodec=mp3, channels=2, venc=x264{ref=2, subme=4}, vcodec=h264}:duplicate{dst=standard{access=http, mux=asf, dst=127.0.0.1:1234}}

Or with vlm to flv conversion

new channel1 broadcast enabled
setup channel1 input http://ip/or-domain:port (This is the source, same goes for the rest)
setup channel1 output #transcode{vcodec=h264,vb=200,deinterlace,ab=32,fps=25,width=256,height=192,acodec=mp3,samplerate=44100}:duplicate{dst=std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=/mediaplayer/stream1.flv},dst=display}

new channel2 broadcast enabled
setup channel2 input http://ip/or-domain:port
setup channel2 output #transcode{vcodec=h264,vb=200,deinterlace,ab=32,fps=25,width=256,height=192,acodec=mp3,samplerate=44100}:duplicate{dst=std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=/mediaplayer/stream2.flv},dst=display}

new channel3 broadcast enabled
setup channel3 input http://ip/or-domain:port
setup channel3 output #transcode{vcodec=h264,vb=200,deinterlace,ab=32,fps=25,width=256,height=192,acodec=mp3,samplerate=44100}:duplicate{dst=std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=/mediaplayer/stream3.flv},dst=display}

control channel1 play
control channel2 play
control channel3 play
-----------------------------------------
From mine experience streaming access via HTTP is not reliable.
Try getting used to UDP streaming. From udp to http output is better with minimal bandwidth.
I tested the same source and streamed it both ways. The HTTP input via HTTP output was like 320KB to 450KB with one user viewing.
With udp input to http output was like 50KB to 80KBmax with one user viewing :)
IBstars

mrosche
Blank Cone
Blank Cone
Posts: 17
Joined: 04 Jul 2008 11:51
VLC version: 2.1.0
Operating System: Windows,Linux,MaxOS,

Re: HTTP Live Streaming multiple quality output

Postby mrosche » 14 Dec 2012 19:51

Hi,

I had the same issue when first trying HLS streaming for my iPad(s) and iPhone(s)...this issue is that when you combine all of your encoding into one VLC process it simply takes time to duplicate the video frames and then re-encode them and finally mux them for your various formats causing the video to lose sync between the various formats and files that are generated (don't forget that you need to take into account cpu speed, I/O speeds, etc as well)...as you have many different formats you are using (I have only h.264 for iGear but with 8 quality steps starting with audio only and ending at 3Mbps), my recommendation would be to use multiple VLC processes (if you are on a Linux box or Mac)...I would recommend having a multi-core machine and dedicate one core per vlc process (processor affinity) and also try to get your input from UDP/RTP multicast...here is an example of a couple of my vlm.confs for HLS streaming (all of the x264 encoding parameters are defined in the cli such as key-frames, mux caching, etc)...as I said, these should be not run in one vlc process, use SEPERATE VLC processes for each transcoding job...my HLS server has been up for 2 months now without one single crash using the configs below and my inputs vary from SD/HD MPEG2/AC3 to SD/HD H.264/AAC...also if you are transcoding HD H.264 you need to start the vlc processes from an X11 window using vdpau on an NVIDIA Graphics to get real-time fps transcoding...software decode and encode for HD H.264 will kill you machine for the other formats you are transcoding to:

Please note that these examples are not for command line execution but for vlm style execution...

Audio Only (mp3 audio):

setup audio input "rtp://@xxx.xxx.xxx.xxx:5100"
setup audio output #gather:transcode{vcodec=none,acodec=mp3,channels=2,ab=64}:duplicate{dst=std{access=livehttp{seglen=1,delsegs=true,numsegs=5,splitanywhere=true,index="/srv/www/htdocs/streaming/audio/stream-audio.m3u8",index-url="/iOSiptv/streaming/audio/stream-audio-##########.mp3"},mux=raw,dst="/srv/www/htdocs/streaming/audio/stream-audio-##########.mp3"}}

Low Bandwidth H.264:

setup lbw input "rtp://@xxx.xxx.xxx.xxx:5100"
setup lbw output #gather:transcode{vcodec=h264,vb=450,acodec=mp4a,channels=2,ab=48,scale=0.30,width=480,height=270}:duplicate{dst=std{access=livehttp{seglen=1,delsegs=true,numsegs=5,index="/srv/www/htdocs/streaming/512k/stream-512k.m3u8",index-url="/iOSiptv/streaming/512k/stream-512k-##########.ts"},mux=ts,dst="/srv/www/htdocs/streaming/512k/stream-512k-##########.ts"}}

Medium Bandwidth H.264:
setup mbw input "rtp://@xxx.xxx.xxx.xxx:5100"
setup mbw output #gather:transcode{vcodec=h264,vb=1372,acodec=mp4a,channels=2,ab=128,scale=0.75,width=640,height=360}:duplicate{dst=std{access=livehttp{seglen=1,delsegs=true,numsegs=5,index="/srv/www/htdocs/streaming/1536k/stream-1536k.m3u8",index-url="/iOSiptv/streaming/1536k/stream-1536k-##########.ts"},mux=ts,dst="/srv/www/htdocs/streaming/1536k/stream-1536k-##########.ts"}}

If you have any more questions, please scream :D

Regards,

Mark

sharbatgula
Blank Cone
Blank Cone
Posts: 15
Joined: 24 Jul 2012 11:57

Re: HTTP Live Streaming multiple quality output

Postby sharbatgula » 28 Oct 2013 13:05

Hi,

I'm also interested in finding a way to synchronize the various quality chunks. At the moment only a single instance of VLC is software encoding two quality streams but they are not in sync. Mark, with your approach with different vlm instance per stream, how do you ever synchronize the outputs for flawless switch, especially if you stop and then restart one of the streams via vlm?

Regards

mrosche
Blank Cone
Blank Cone
Posts: 17
Joined: 04 Jul 2008 11:51
VLC version: 2.1.0
Operating System: Windows,Linux,MaxOS,

Re: HTTP Live Streaming multiple quality output

Postby mrosche » 28 Oct 2013 16:02

Hi,

I have given up on this with VLC as the solution cannot be achieved with VLC (has to do with iframe sync n H.264). To achieve truely seamless switchover I now use a commercial product that also supports HLS encryption (which was also was one of my requirements. I do use VLC to feed my original stream to this solution though...I am a big fan of VLC but for some specific use cases it does not offer what I need...,

Cheers!!!

sharbatgula
Blank Cone
Blank Cone
Posts: 15
Joined: 24 Jul 2012 11:57

Re: HTTP Live Streaming multiple quality output

Postby sharbatgula » 02 Nov 2013 10:25

Thanks for the info. I still haven't given up on this as I've seen a commercial OTT solution supposedly built around VLC using Erlang language to control all the instances and the bitrate switching is perfect. My last hope is to daisy chain the transcode modules so each subsequent transcode module is using less resources to transcode to the next lower bitrate. I might also try using ffmpeg directly to achieve this.
Would you like to share on private message which commercial product are you using?

Regards

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: HTTP Live Streaming multiple quality output

Postby Jean-Baptiste Kempf » 05 Nov 2013 20:53

Wowza, as most people do.

It is doable with VLC though, but hard.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

sharbatgula
Blank Cone
Blank Cone
Posts: 15
Joined: 24 Jul 2012 11:57

Re: HTTP Live Streaming multiple quality output

Postby sharbatgula » 06 Nov 2013 08:15

Ok, given that a few people are interested in the same, can you help and give us instructions and sample syntax to achieve that? We need time coherent multiple resolution/bitrate streams.

Thank you!

raytiley
New Cone
New Cone
Posts: 2
Joined: 13 Nov 2013 22:08

Re: HTTP Live Streaming multiple quality output

Postby raytiley » 13 Nov 2013 22:50

Just wondering if anyone has gotten this to work in VLC and has an example?

Seems to me in order to do this you would need to segment the video then duplicate the segments and transcode each one separately. Not sure how to do this with VLC though.

The other option I see is to transcode and segment the highest quality and then transcode those segments into lower quality segments. Seems like you would getter lower quality than is possible at the target bitrate since the source is already compressed.

Can anyone point me in the right direction for this?

Thanks

-ray


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 12 guests