HTTP Live Streaming with VLC

Well, it took "a while" but I finally got HTTP Live Streaming working with VLC. Downloading and compiling the latest from Videolan's Git repo was required ("1.2.0-git Twoflower" here). I might add that even though on the box that I did this I've compiled a lot of different programs (an Ubuntu installation that has gone through multiple dist-upgrades so it's a few years old and has a lot of packages (2344 atm) installed), quite a few external -dev packages relating to audio and video had to be apt-get'ed to make things work. Below is the command to make VLC read a DVD and generate a segmented stream of H264 video and AAC audio to directory /var/www/html-video-stream/x/ on our local web server. In an IRL situation we would perhaps run the transcoder and segmenter instances on separate machines, or if we already had a suitable H264 stream source (like a camera) we could skip the transcoding step altogether.
vlc -v -I "dummy" dvdsimple:///dev/scd0 »
:sout="#transcode{vcodec=h264,vb=100, »
venc=x264{aud,profile=baseline,level=30,keyint=30,ref=1}, »
aenc=ffmpeg{aac-profile=low},acodec=mp4a,ab=32,channels=1,samplerate=8000} »
:std{access=livehttp{seglen=10,delsegs=true,numsegs=5, »
index=/var/www/html-video-stream/x/stream.m3u8, »
index-url=}, »
mux=ts{use-key-frames}, »
  QuickTime X (fanboys have had this since Snow Leopard) supports HTTP Live Streaming, so in order to show the above stream on a web page in Safari using the <video> tag, we can do the following:
<video autoplay loop controls>
  <source src="" »
   type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'/>
  <!-- additional sources here -->
  Although I'm not sure if this will work in a situation where we attempt to feed H264 to clients that don't support HTTP Live Streaming, that is, we have an additional <source> element that points to a "regular" H264 HTTP stream. However, adding Ogg/Theora and WebM/VP8 support should not cause problems – I just haven't been able to make VLC output those (properly) yet. HTML5 video tag streaming support in different browsers is also one big question mark.

Tagged with:

Categorised as: