5

I have a raspberry and multiple cameras connected to it, now I want to be able to see the picture in most effective way. Running an xserver on there and using vnc or something to watch the image is pretty ineffective and slow, consuming a lot of cpu.

Is there a simple way to do this in terminal? I can store video using aconv directly to a file in terminal, but what if I wanted to get the output of camera's accessible over network so that I can directly stream / display it on 3rd PC (running linux)? I saw some options using apache server, but that seems to be ineffective as well, I need something what eats nearly no memory and cpu

4
  • Can you provide more information about the cameras you are using?
    – syb0rg
    Nov 5, 2013 at 22:30
  • Isn't that irrelevant? This question isn't related to specific hardware, it's rather a general question about video streaming - receiving assuming you have a working camera. I can provide you technical details, but I really think it doesn't really matter, I would expect universal answer for any camera that is recognized by kernel...
    – Petr
    Nov 5, 2013 at 22:48
  • That information isn't irrelevant, maybe I should be less specific. Are you referring to USB cameras, or the Raspberry Pi cameras?
    – syb0rg
    Nov 5, 2013 at 22:49
  • USB camera it is
    – Petr
    Nov 5, 2013 at 22:54

6 Answers 6

6

The easiest way I have found, to get a live videofeed from an headless raspberry pi, with a raspberry pi camera.

This solution works right out of the box, without installing additional software on the PI.

On the PI:

raspivid -t 0 -l -o tcp://0.0.0.0:3333

On the Computer, one can stream with VLC:

vlc tcp/h264://192.168.66.154:3333

(assuming 192.168.66.154 is the PI's IP address)

4
  • Hello and welcome. As has been pointed out at your other answer verbatim copies of answers is strongly discouraged. If the same answer indeed applies to both question one should be closed as a duplicate to the other. In this particular case however I think the questions are not dupes, as this Q does address multiple (non raspi-cam) cameras while the other is specifically about the Pi cam. In this light I think your answer here is misleading as it focuses on the Pi cam whereas the question is supposedly broader than that.
    – Ghanima
    Aug 25, 2017 at 16:23
  • 1
    For the VLC on Mac it is /Applications/VLC.app/Contents/MacOS/VLC tcp/h264://192.168.66.154:3333
    – tomas789
    Mar 22, 2020 at 16:23
  • The latency is rather high with this solution and the video isn't smooth (cuts out regularly). Is there any solution to this?
    – 9a3eedi
    Dec 13, 2020 at 13:00
  • I dug out my old raspberry pi 3 and can confirm this works out of the box. you can run tomas789's command or set an alias (alias vlc='/Applications/VLC.app/Contents/MacOS/VLC'). Thank you!
    – Casey L
    Jun 8, 2021 at 18:00
5

I've got my raspberry pi camera module streaming work.

Solution 1:

on your Raspberry Pi:

sudo apt-get install vlc
raspivid -o - -t 0 -n -w 320 -h 200 -fps 24 | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264

# -w 320 and -h 200 is to restrict video size as 320x200

on your PC:

ffplay http://raspberrypi.local:8090 # raspberrypi.local is the ip of your rpi, mine has been set with a domain name by avahi (zeroconf service)

or

you can open your VLC or mplayer to view your url at http://raspberrypi.local:8090

Solution 2:

Due to version of ffmpeg package on Debian/Raspian is too old, we need livav (debian and raspbian included) or custom-built ffmpeg to perform following:

On Raspberry Pi:

raspivid -o - -t 0 -n -w 320 -h 200 -fps 24 | avconv  -i - -f rtp rtp://192.168.1.122:8558

output as:

 avconv version 0.8.13-6:0.8.13-1+rpi1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 29 2014 02:09:52 with gcc 4.6.3
[h264 @ 0x10e6680] max_analyze_duration reached
[h264 @ 0x10e6680] Estimating duration from bitrate, this may be inaccurate
Input #0, h264, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0.0: Video: h264 (High), yuv420p, 320x200, 25 fps, 25 tbr, 1200k tbn, 2400k tbc
[buffer @ 0x10dc160] w:320 h:200 pixfmt:yuv420p
Output #0, rtp, to 'rtp://192.168.1.122:8558':
  Metadata:
    encoder         : Lavf53.21.1
    Stream #0.0: Video: mpeg4, yuv420p, 320x200, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg4)
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.1.122
t=0 0
a=tool:libavformat 53.21.1
m=video 8558 RTP/AVP 96
b=AS:200
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=1

copy:

v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.1.122
t=0 0
a=tool:libavformat 53.21.1
m=video 8558 RTP/AVP 96
b=AS:200
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=1

to your local PC as a .sdp file, eg, streaming.sdp

On your local PC:

ffplay -i streaming.sdp

there are many other alternative methods(rtsp, tcp, udp, or even setup a streaming server by ffserver) to streaming your camera video data to your pc, but what I was struggling with, is that I didn't realize the ffmpeg version was too old to proceed camera video data!

2

You can use ffmpeg to manipulate the data and to stream them. From your question I guess you do not want the camera pictures to be publicly available, so you can keep it simple with point-to-point data transfer.

So in general, first you need capture the video from camera.

Regarding the processing power of Pi, you cannot do much with the data, but in general, mpeg2 is reasonably fast. You better first try on faster computer, how to put things together and then strip on fanciness to allow Pi to do it.

Other two things remain - putting more streams into one.

And then stream the data over network. Essentially the simplest way is to set ffmpeg on Pi to listen on tcp:// connection and you connect then from outside.

The concrete commandline options are very dependant on your requirements, cameras, so I did not put any of them here.

Additionally, there is unlucky situation regarding video processing, and raspberry has chosen the libav way. I have not tested it, it might work the same as ffmpeg does. If not, you have to compile recent ffmpeg from sources (overnight on raspberry).

1

I am running a Microsoft web cam, a logitec web cam and a KAZAN (chinese with cut filter on solonoid) and streaming them all three with mjpg-streamer. I get a good image from each. Here is how I start it. Notice all three are deamon items

export LD_LIBRARY_PATH="/etc/mjpg-streamer"

/etc/mjpg-streamer/mjpg_streamer -b -i "input_uvc.so -d /dev/video0 -f 3 -r 1280X720" -o "output_http.so -p 8080 -w ./www "

/etc/mjpg-streamer/mjpg_streamer -b -i "input_uvc.so -d /dev/video1 -f 3 -r 1280X720" -o "output_http.so -p 8081 -w ./www "

/etc/mjpg-streamer/mjpg_streamer -b -i "input_uvc.so -d /dev/video2 -f 3 -r 1280X720" -o "output_http.so -p 8082 -w ./www "

Here is the HTML source for viewing except on MSIE Win 8 as they evidently don't support mjpg I'm not sure. I had to trim the header 'cause the server thought I was adding HTML

<table style="border: thick ridge #800000" width="100%">
    <tr>
        <td width="30%" >
            <img src="http://192.168.0.157:8080/?action=stream" alt=""  width="100%"  />
        </td>

        <td width="30%">
            <img src="http://192.168.0.157:8081/?action=stream" alt=""  width="100%" />
        </td>
        <td width="30%">
            <img src="http://192.168.0.157:8082/?action=stream" alt=""  width="100%" />
        </td>
    </tr>
</table>
<br />
1

I get pretty good results using pi 3 (stretch) with the raspivid command listed by Per Hansen above and OMXPlayer, an Open Max video player on the raspberry pi.

To start the stream:

raspivid -t 0 -l -o tcp://0.0.0.0:3333

To view the stream on local pi:

omxplayer tcp://192.168.2.2:3333

Where 192.168.2.2 is the IP address of the pi with the camera.

The video is very close to real-time, but suffered occasional lag and speedups, but often the lag might be only a couple of milliseconds.

I am using recently updated pi's with the new ffmpeg (bundled) etc.

0

I found a lot of information in this Raspberry Pi forum post; they are trying to accomplish the same thing you are. To do so, they installed and setup a MiniDLNA media server on the Raspberry Pi.

You need a DLNA client on your computer to receive the stream. Here is a list from Wikipedia.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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