Streaming LIVE webcam feed using GStreamer . A Python-based GStreamer application for streaming video between a sender and receiver using UDP transmission over same network.
- Linux System
- Ensure both sender and receiver are on the same network.
- Adjust firewall settings if necessary to allow UDP communication.
- sender.py: Python script for streaming video from a device to a specified IP address and port.
- receiver.py: Python script for receiving and displaying video streams on a specified port.
- In terminal type
ip addroripconfigfind your ipv4 address from there. - Now in Receiver's terminal type
ping sender_IPand in Sender's terminal typeping receiver_IP. - If both are able to communicate with each other then Proceed.
sudo apt-get install python3
sudo apt install python3-pip
pip install -r requirements.txt (On Both Sender and Receiver Side)
python3 sender.py -ip <destination_ip> -port <port_number> -device <device_index>
e.g python3 sender.py -ip 192.168.1.1 -port 8081 -device 2
You can resize the stream size also by changing width=640,height=480
Replace <destination_ip> with Receiver IP Address, <port_number> with any Open or Free Port.
Replace <device_index> with (0,1,2...) (default is 0) , check using /dev/device* in terminal for the device index.
python3 receiver.py -port <port_number>
e.g python3 receiver.py -port 8081
Replace <port_number> with the same port used by the sender.
- Use New Terminal Window everytime for another webcam streaming while Transferring other webcam Stream or Viewing stream.
- Use different ports while executing the sender side command, if the receiver end is not same use IP Address of the other receive and another Unused/Open Port.
- Execute the Receiver Side command by Specifying the used port for particular required stream into the new terminal window.
- New Window will Pop-Up use that to view streams
- You can resize the stream size also by changing
width=640,height=480
sudo apt-get update
sudo apt-get install python3
sudo apt-get install gstreamer1.0-tools
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! jpegenc ! rtpjpegpay ! udpsink host=RECIEVER_IP_ADDR port=ANY_OPEN_PORT
Here /dev/video0 — gives the stream of default webcam.
For using Multiple Cameres change the device ( /dev/video[otherNumber] ) for other connected webcam. By checking using (/dev/video*)
gst-launch-1.0 -e -v udpsrc port=PREVIOUS_USED_PORT ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideosink