1

I just started experimenting with a new Raspberry Pi 3 Model B with the latest Raspbian installed. I was looking for the best way to stream from the camera module and I have found different answers, some of which might be outdated. In particular, some answers seem to suggest that the best way is to load the V4L2 module and then stream directly from /dev/video0. I have come to believe that this method is now considered deprecated, since loading the bcm2835-v4l2 module does not create /dev/video0 on my installation of Raspbian. My conclusion is that the best way to stream video from the Pi camera is to use the raspivid approach.

Are my conclusions correct? Or is there perhaps something wrong with my Raspbian?

EDIT This is what I get out of dmesg after modprobe

[  385.249635] media: Linux media interface: v0.10
[  385.275426] Linux video capture interface: v2.00
[  385.311687] bcm2835-v4l2: scene mode selected 0, was 0
[  385.313824] bcm2835-v4l2: V4L2 device registered as video0 - stills mode > 1280x720
[  385.318747] bcm2835-v4l2: Broadcom 2835 MMAL video capture ver 0.0.2 loaded.
pi@raspberrypi:~ $ /dev/
block/  bus/    char/   disk/   fd/     input/  mapper/ mqueue/ net/    pts/    raw/    shm/    snd/  
  • Best how? Easiest to setup/configure? best performance? Most extensible? Is this all the Pi will do (stream video). Have you looked at motioneyeos? – Steve Robillard Jul 22 '17 at 20:18
  • 1
    Best as in minimum delay I'd say. It wouldn't make sense to use a method that streams the content twice (e.g. directly from /dev/video0 and then feed to vlc). – Phoenix87 Jul 22 '17 at 20:44
4

By stream I assume you mean over the network. I recently researched the same question (specifically, streaming over RTSP) and these are the best options out there:

I tried v4l2rtspserver first since it seemed the simplest. I'm happy with the result so I didn't try the other 2, but they seem viable options.

Re V4L2: it's not deprecated in any way. In fact it's what v4l2rtspserver uses, as you might guess from the name. Once the module is loaded it should create a /dev/video0 immediately. If you're not seeing it there may be a problem with your setup. Can you record video with raspivid?

If you don't need a standard format stream, there's also the option of using gstreamer on both ends of the connection:

  • On the Raspberry Pi:

    raspivid -n -t 0 -w 640 -h 480 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=0.0.0.0 port=5000

  • Display the stream on another computer (substitute IP as appropriate):

    gst-launch-1.0 -v tcpclientsrc host=10.10.5.208 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

This has one advantage: the stream has almost no delay, which I could never manage to get with any of the methods that stream over RTSP

  • thanks for your answer. When I do sudo modprobe bcm2835-v4l2 there is no device /dev/video0, nor anything that looks related to that in /dev. – Phoenix87 Jul 23 '17 at 17:01
  • Do any of the options that don't require V4L2 (like raspivid or the gtreamer commands above) work? Just to sort out whether the camera is setup properly and enabled, raspivid is the fastest option. If you have a monitor connected to your PI, raspivid -t 0 will show you the video in real time; otherwise raspivid -o somefile.h264 will save 5 seconds of video to a file. – Pedro Lopes Jul 24 '17 at 7:24
  • RaspiVid works, I managed to stream with via VLC. I was just wondering if this is the optimal approach or if there is a better solution, given that some of the post that I've seen seem to suggest that VLC after RaspiVid is unnecessary – Phoenix87 Jul 24 '17 at 8:00
  • 1
    The reason I didn't use VLC for RTSP streaming was twofold: it has 4-5 seconds of lag (v4l2rtspserver is down to about 2s), and trying to run cvlc as a service is a bit funky. Regarding V4L2: check the dmesg output when you are modprobeing the driver, I suspect there will be some error logs. – Pedro Lopes Jul 24 '17 at 9:16
  • 1
    However Lao's answer to this question raspberrypi.stackexchange.com/questions/23182/… is not working for me and I get a bunch of errors from vlc (including something related to DISPLAY, which might be caused by me controlling the Pi headlessly). If I open the remote location I don't see the stream – Phoenix87 Jul 24 '17 at 18:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.