perjantai 3. joulukuuta 2010

Streaming live DVB using VLC

The problem: i needed to stream live DVB broadcast from home to the outside world. Limiting factors are bandwidth (1Mbps up) and CPU (Core 2 Duo @ 1.8Ghz). I found out a lot of guides on how to do it using VLC, but only a few worked. Source for the video in this case is a USB DVB-C tuner, but any DVB tuner which VLC sees should work.

After a lot of tuning, the best result was obtained with the following command line:

cvlc -v channels.conf \
--sout \

This will give a average of 700kbps ogg theora stream scaled a bit down and with 16fps
frame rate. This stream doesn't include audio, so you'll probably want to set acodec=vorbis
and audio bitrate (ab=) something sensible.

Stream is served at port 8081 and can be viewed locally at url http://localhost:8081/ using VLC or other video player. You'll need the channels.conf file (google how to obtain it). You can also use vlc instead of cvlc to get GUI. You can change channel from playlist window. This can probably also be done on command line somehow.
Set threads= to number of cores in your CPU. On Core 2 Duo it's naturally 2.

The quality can be described as "youtube-like". You don't want to watch Avatar on this but for some basic stuff such as sports, talkshows and news it's way better than no stream at all. Naturally if you have more bandwidth, increase the vb parameter. With 1M uplink 800kbps resulted in jerky video, so 700 is pretty close to optimum.

Notes on some other codecs: x264 encoder didn't obey the bitrate parameter at all and was unusable. ffmpeg created corrup video (random bright colors et all) so i decided to use ogg theora which worked really well.

Ei kommentteja: