5

I have tried to install Motion to stream from the cam. So I went to: RASPBERRYPI-IP:8080/8081 but it didn't show me my stream. I have no idea how Motion works and I am curious if this is the best and easiest way to try to stream video from my picam. Also if you have a good tutorial for me about this matter, I would love to use it. So what am I doing wrong?

7

There's a simple way to do it with VLC, this post explains step by step how to do it, in few words this is the way you do it:

After having the camera fully set and ready to be used(connected and enabled), now you need to download the package that will perform the live streaming functionality, getting it is as simple as just executing this command in your RPi Command Terminal:

sudo apt-get install vlc

Once the vlc package is installed you can stream the content using the following command:

raspivid -o - -t 0 -hf -w 800 -h 400 -fps 24 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8160}' :demux=h264

This command starts recording using the camera and sets the output size to be 800 width and 400 height with a rate of 24 frames per second then pipes the output to cvlc to stream the content using http access protocol in the port 8160 using the encoding video format h.264, the video is ready to be consumed in the location “http://raspberrypi.ip:8160/

The post even has a video of how to do it.

Hope it Helps...

Regards!

3

Are you trying to connect via remote ? Maybe you need to change this:

# Restrict stream connections to localhost only (default: on)
stream_localhost on

Here's a example for 1FPS. Adjujst it for your needs:

############################################################
# Live Stream Server
############################################################

# The mini-http server listens to this port for requests (default: 0 = disabled)
stream_port 8081

# Quality of the jpeg (in percent) images produced (default: 50)
stream_quality 50

# Output frames at 1 fps when no motion is detected and increase to the
# rate given by stream_maxrate when motion is detected (default: off)
stream_motion off

# Maximum framerate for stream streams (default: 1)
stream_maxrate 1

# Restrict stream connections to localhost only (default: on)
stream_localhost off

Do you even have a connection to the cam ? Can you save snapshots ?

  • How do I even take snapshots? – Loko Nov 6 '13 at 10:41
  • edit /etc/motion/motion.conf and search this: snapshot_interval 0 and change it to 1 to save a picture every second. You need to adjust target_dir and snapshot_filename too. – Baris Kilic Nov 6 '13 at 10:42
  • I cant check now but I probably do have connection to the cam but I can't see the screen of the cam when I go to my raspberrypi-ip:8080 or raspberrypi-ip:8081 – Loko Nov 6 '13 at 10:45
  • Am I right, that you run it in daemon mode ? If yes, disable it, run motion and read the output. If you don't understand it, post it here :) – Baris Kilic Nov 6 '13 at 12:27
  • I do run in daemon mode, I will disable when I am home. – Loko Nov 6 '13 at 12:37
2

There is a summary of the various protocols VLC can stream through on this page, together with their advantages/drawbacks and a link to a long discussion on the Raspberry Pi forums.

To summarize:

raspivid -o - -t 0 -w 960 -h 540 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

will stream video through the RTP protocol on port 8554 (arbitrary), which is claimed to tbe the most reliable but difficult to forward through a router (for streaming through the internet instead of a local network). See the link for how to use other protocols (HTTP for easy forwarding or HLS for native playback on iOS devices).

I found that RTP has the lowest latency (about 3 s for 800 by 600 video in my case) and uses the least CPU.

The stream can be played on another computer with e.g. VLC using File -> Open Network... and entering rtsp://pi-ip:8554/ (substitute the IP number of the Pi for pi-ip and make sure you enter the closing /). VLC works on iOS devices as well and can play the stream.

To use non-standard frame rates, it is important to set the framerate both for raspivid and cvlc. Otherwise playback will be glitchy as cvlc tries to send data faster than it is receiving it. For example, for 10 fps:

raspivid -o - -t 0 -fps 10 -w 960 -h 540 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264 :h264-fps=10

The -rot option is often useful as well if the camera is not oriented upside up. It rotates the image with the specified number of degrees.

0

I answered a similar question over here, where I suggested the use of RPi Cam Web Interface, which is very easy to set up and use, and has a huge feature set, plus it streams with a very good quality/framerate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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