How to Live Stream from Raspberry Pi Camera Easily
To live stream from a Raspberry Pi camera, use the
raspivid command to capture video and pipe it to ffmpeg or netcat for streaming over the network. This setup sends real-time video to another device or server for viewing.Syntax
The basic command to start live streaming from the Raspberry Pi camera uses raspivid to capture video and streams it over the network using netcat or ffmpeg.
raspivid -o - -t 0 -fps 25 -w 1280 -h 720: Captures video with no timeout, 25 frames per second, and 1280x720 resolution, outputting to stdout.|: Pipes the video output to the next command.nc [IP] [PORT]: Sends the video stream to the specified IP and port using netcat.
bash
raspivid -o - -t 0 -fps 25 -w 1280 -h 720 | nc 192.168.1.100 5000
Example
This example shows how to stream video from the Raspberry Pi camera to a computer on the same network using raspivid and netcat. On the Raspberry Pi, run the streaming command. On the receiving computer, use nc and mplayer to view the stream.
bash
# On Raspberry Pi (streaming): raspivid -o - -t 0 -fps 25 -w 1280 -h 720 | nc 192.168.1.100 5000 # On receiving computer (viewing): nc -l -p 5000 | mplayer -fps 25 -cache 1024 -
Output
The receiving computer opens a window showing the live video stream from the Raspberry Pi camera.
Common Pitfalls
- Wrong IP address: Make sure the IP in the
nccommand matches the receiver's IP. - Firewall blocking ports: Ensure the chosen port (e.g., 5000) is open on both devices.
- Missing software: Install
raspivid,netcat, andmplayerbefore running commands. - Camera not enabled: Enable the camera interface in Raspberry Pi settings.
Example of a common mistake and fix:
# Wrong (missing IP or wrong port) raspivid -o - -t 0 | nc 192.168.1.200 6000 # Correct (use correct IP and open port) raspivid -o - -t 0 | nc 192.168.1.100 5000
Quick Reference
Summary tips for live streaming from Raspberry Pi camera:
- Use
raspividto capture video. - Stream with
netcatorffmpeg. - Match IP addresses and ports on sender and receiver.
- Open necessary network ports and disable firewalls if needed.
- Enable camera in Raspberry Pi configuration.
Key Takeaways
Use raspivid to capture and stream video from the Raspberry Pi camera.
Pipe raspivid output to netcat or ffmpeg to send video over the network.
Ensure IP addresses and ports match on sender and receiver devices.
Open network ports and enable the camera in Raspberry Pi settings.
Install required software like netcat and mplayer before streaming.