~2012
Easy http streamer with VLC
Today I needed a simple setup for streaming a camera locally on the network. I could do this with ffmpeg and ffserver and so but that's a whole lot more work than doing this with VLC which has a webserver built-in. Getting the right command line with this was a bit cumbersome however with some digging through the available docs I managed to get the right parameters.
So run this in a terminal:
cvlc --verbose 2 "v4l2://" --v4l2-dev /dev/video0 --v4l2-fps 25 ':sout=#transcode{vcodec=mpeg2,vb=8000,scale=0,acodec=none}:http{mux=ts,dst=:8080/}'
I have been tweaking a bit with the parameters but found using MPEG2 with a high bit rate to work best. I'm not using any audio. using H264 or MPEG4 gave me lots of errors.
Some more tweaks
Instead of using
1.-dev-v4l /dev/video0
you can also use
v4l:///dev/video0:width=640:height=480
More docs available here
Use this as a bash script which is handy for tweaking
#!/bin/bash
OUT=':sout=#transcode{vcodec=mpeg2,vb=8000,scale=0,acodec=none}:http{mux=ts,dst=:8080/}'
cvlc --verbose 2 "v4l2://" --v4l2-dev /dev/video0 --v4l2-fps 25 "$OUT"
If you want to make sure the stream never stops use a script like this
#!/bin/bash
OUT=':sout=#transcode{vcodec=mpeg2,vb=8000,scale=0,acodec=none}:http{mux=ts,dst=:8080/}'
while true
do
cvlc --verbose 2 "v4l2://" --v4l2-dev /dev/video0 --v4l2-fps 25 "$OUT"
done