3

I'm trying to set up HTTP live streaming (HLS) with a webcam, just over the local network, using VLC. I've successfully been able to do other types of streaming (e.g. http) with the same webcam, but I'd like to get HLS working (the livehttp module) because of it's extra features.

The camera I'm using is a USB Logitech webcam and shows as HD Pro Webcam C920.

Here is my command. I've tried to change around the settings, but no matter what I do the video doesn't show up (in the browser). It seems to load the page and it says "Live Broadcast" but no video. See screenshot at the bottom of the question.

cvlc -v v4l2://"$cam" --sout="#transcode{vcodec=h264,fps=20,vb=512,scale=1,acodec=none,venc=x264{aud,profile=high,level=60,keyint=15,bframes=0,ref=1,nocabac}}:std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=/var/www/html/streaming/mystream.m3u8,index-url=10.0.0.19/streaming/stream-###.ts},mux=ts{use-key-frames},dst=/var/www/html/streaming/stream-###.ts}}"

($cam is the path to the camera. In my case it is /dev/video0. I didn't write it here, since it changes depending on the cameras connected.)


Edit (Jan 2, 2025):

I haven't gotten HLS working using VLC alone, but I did get it working using ffmpeg as the segmenter. It was very laggy, so much so that it's unusable. I was hoping to get it working with just VLC, since I thought it might work better (VLC does have support for HLS, using livehttp). I'll post the code here, although it's not what I wanted to use.

cam=/dev/video0; cvlc -v v4l2://"$cam":chroma=yuyv:width=1280:height=720 --sout='#transcode{vcodec=h264,fps=15,venc=x264{preset=ultrafast,tune=zerolatency,keyint=30,bframes=0,ref=1,level=30,profile=baseline,hrd=cbr,crf=20,ratetol=1.0,vbv-maxrate=1200,vbv-bufsize=1200,lookahead=0}}:standard{access=http{mime="video/MP2T"},mux=ts,dst=10.0.0.19:8081}' --live-caching=200

run at the same time, in a separate terminal

ffmpeg -v debug -fflags nobuffer -i http://10.0.0.19:8081 -r 15 -vsync 2 -copyts -copytb 1 -codec copy -map 0 -f segment -segment_time 2 -segment_list /var/www/html/streaming/test.m3u8 -segment_format mpegts -segment_list_flags +live /var/www/html/streaming/teststream-%09d.ts

(You need to change the 10.0.0.19 to your own local IP address. Then in the browser, you type your IP and the path, in my case 10.0.0.19/streaming/test.m3u8. I only got it working in Safari.)

I should also mention, before using HLS, you need to install & set up the server, and create a folder. Here is the code I used for that.

# initial server setup for HLS
# (make sure apache2 installed first)
if [[ ! -d /var/www/html/streaming ]]; then 
  sudo mkdir /var/www/html/streaming
  sudo chown $USER:$USER /var/www/html/streaming
  sudo chmod -R +rwx /var/www/html/streaming
fi

You might also need to install v4l-utils to run any of these commands (sudo apt install v4l-utils). I'm not sure. Obviously VLC needs to be installed as well-- I installed it through the Software Manager.

screenshot

htmlcat
  • 131

0 Answers0