udp,raspberry-pi,gstreamer , Stream webcam video with gstreamer 1.0 over UDP to PC

Stream webcam video with gstreamer 1.0 over UDP to PC


Tag: udp,raspberry-pi,gstreamer

Im trying to stream video from a Raspberry Pi (on Raspbian) to a Windows 7 PC like in this video: https://www.youtube.com/watch?v=lNvYanDLHZA

I have a Logitech C270 connected to the Raspberry Pi, and have managed to stream webcam video over TCP using:

gst-launch v4l2src device=/dev/video0 ! \
'video/x-raw-yuv,width=640,height=480' ! \
x264enc pass=qual quantizer=20 tune=zerolatency ! \
rtph264pay ! tcpsink host=$pi_ip port=5000

from my Pi. Receive this using VLC works, but with a 3 sec delay. I want to do this over UDP to get a shorter delay (correct me if I'm wrong). But cannot for the life of me figure it out. I have tried following:

gst-launch-1.0 v4l2src device=/dev/video0 ! \
'video/x-raw-yuv,width=640,height=480' ! \
x264enc pass=qual quantizer=20 tune=zerolatency ! \ 
rtph264pay ! udpsink host=$pc_ip port=1234


gst-launch-1.0 udpsrc port=1234 ! \ 
"application/x-rtp, payload=127" ! \
rtph264depay ! ffdec_h264 ! fpsdisplaysink sync=false text-overlay=false

For the Pi and PC side, respectively (taken from Webcam streaming using gstreamer over UDP) but with no luck. (tried to change the video/x-raw-yuv to fit 1.0 version but still without luck)

Any hints would be highly appreciated!


With the raspi camera (not the webcam) the following works:

Windows batch script:

@echo off
cd C:\gstreamer\1.0\x86_64\bin
gst-launch-1.0 -e -v udpsrc port=5000 ! application/x-rtp, payload=96 !        
rtpjitterbuffer ! rtph264depay ! avdec_h264 ! fpsdisplaysink sync=false    

Raspberry Pi Bash Script:

raspivid -n -t 0 -rot 270 -w 960 -h 720 -fps 30 -b 6000000 -o - | gst-       
launch-1.0 -e -vvvv fdsrc ! h264parse ! rtph264pay pt=96 config-interval=5 !   
udpsink host=***YOUR_PC_IP*** port=5000

But I cannot figure out how to use to webcam instead of the raspberry pi camera (i.e. v4l2src instead of raspivid) in the same manner

Edit 2

The following works, but is very slow and has a huge delay:


gst-launch-1.0 -vv -e v4l2src device=/dev/video0  \
! videoscale \
! "video/x-raw,width=400,height=200,framerate=10/1" \
! x264enc pass=qual quantizer=20  tune=zerolatency  \
! h264parse \
! rtph264pay config-interval=5 pt=96  \
! udpsink host=$myip port=$myport


gst-launch-1.0 -e -v udpsrc port=5001 ! ^
application/x-rtp, payload=96 ! ^
rtpjitterbuffer ! ^
rtph264depay ! ^
avdec_h264 ! ^
autovideosink sync=false text-overlay=false

I now suspect that (thanks to hint from @Mustafa Chelik) that the huge lag is due to the fact that the raspberry pi has to encode the webcam video, while the raspberry pi video is already encoded, not sure if this makes sense though?


Found hints to the solution from http://www.z25.org/static/rd/videostreaming_intro_plab/

The following worked very well for streaming video from Logitech c270 on raspberry pi to a windows 7 pc:

PC side:

gst-launch-1.0 -e -v udpsrc port=5001 ! ^
application/x-rtp, encoding-name=JPEG,payload=26 ! ^
rtpjpegdepay ! jpegdec !  ^

RPi side:

gst-launch-1.0 -v v4l2src device=/dev/video0  \
! "image/jpeg,width=1280, height=720,framerate=30/1" \
! rtpjpegpay \
! udpsink host=$myip port=$myport

I suspect that it was the encoding of the webcam video to h264 that was too slow on the raspberry pi, however the webcamera already gave jpeg frames and thus no encoding was nescessary using "image/jpeg"


os.hostname() to return an IP

I have this raspberryPi with Node.JS running on top of it. By calling os.hostname(), the Pi returns "raspberry". I'm aware on how to modify this behaviour. What I don't know is how to do so in order to have it return an IP. The raspberry is connected in a distributed...

How to Read Files Stored in Raspberry Pi Directly to Window Using R

I'm attempting to read files stored in Raspberry Pi (Raspbian) directly to Windows 7 using R. To be specific, here are what I've done so far. 1. Install R 3.1.2 on Windows 7 2. Install Raspbian on Raspberry Pi, stored some text data files in Raspberry Pi. 3. Attempt to...

send udp message from PC(windows)(client) to android phone(server) not working

I want to send a UDP message from PC(server) to my android phone 4.2(client) using WIFI connection. My phone and PC are connected via wireless router. But no message is received from phone to mobile. I have understood from debugging that the program is waiting at socket.receive(packet);. So, there is...

My While True loop is getting stuck in python

Hello I have been working on an infinite While True loop for the main file in my python code. I am working on a Raspberry Pi and my goal is that whenever one of the GPIO Pins senses an input it will print out a string. However When I push...

Arduino serial works fine with Debian but hangs with Raspbian

I'm working on a personal home automation project. On the server side, I have an Arduino Pro Mini with: a 433 MHz TX module on pin 2 a 433 MHz RX module on pin 3 a DHT22 probe on pin 4 (with 10k pull-up) a DHT22 probe on pin 5...

Raspbian log files

Where can I find all boot, driver or kernel related logs on a Raspbian? Could you please reply with a list as follows: Driver logs - /something/somethingelse.log Thanks!...

Raspberry Pi: printf() doesn't work with wiringPi

I'm trying a simple code that using wiringPi as here: #include<wiringPi.h> #include<stdio.h> int main(void){ int i; wirintPiSetup(); pinMode(0,OUTPUT); //a single LED pinMode(8,INPUT); //tactile switch for(;;){ delay(500); //push tactile switch and LED is turning on if(digitalRead(8)) digitalWrite(0,0); else digitalWrite(0,1); printf("%d",digitalRead(8)); } } I expected a result of printf() is output to...

How deploy an large number iBeacons

I want deploy a large number of iBeacons with the same UUID because we can't access dynamically to the UUID of the beacons detected. What is the limit number of the maximum Beacons with the same UUID ? I found some discussions with a number of 65000 approximately, is it...

Raspberry PI USB to RS232 adapter Receiving Only Ctrl Chars

I'm using a USB to RS232 cable for get communication with a pure rs232 device. With pyserial lib a got this code running in loopback tx -> rx cable pins. Setting the port: def __init__ (self, baudrate,timeout,parity,stopbits,bytesize): try: #self.s = serial.Serial(port="'/dev/ttyUSB0'",baudrate=baudrate,timeout=timeout,parity=parity,stopbits=stopbits,bytesize=bytesize) #self.s = serial.Serial("/dev/ttyUSB0",9600) self.s=serial.Serial( "/dev/ttyUSB0", baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,...

Detecting incoming port for TFTP data?

I'm working on implementing a TFTP client (UDP socket). Currently I have to switch off the entire firewall on my Windows 8 machine or else the data doesn't reach the TFTP client. The outgoing connect request happens on port 69, but the first data packet from the TFTP server is...

Using camera shutter to trigger MPU6050 on raspberry pi

I've connected DSLR to RPi by GPIO; and MPU6050 to RPi using I2C. I'm trying to record the gyro and accelerometer data in a small time window (typically less than 50ms) when I press camera shutter button. My desired sampling rate is somewhere in between 500Hz to 1000Hz. And I...

Implementing VOIP over udp, what is the approach to take when the player cannot cope up with received packet's speed

I am implementing p2p voice over IP on android, using UDP, openSL and some audio compression. The voice chat works good when 2 peers are connected, and the lag is steadily about 100ms. When a third peer connects, one or more peer progressively accumulate lag, reaching 15+ seconds in some...

Python Flask persistent object between requests

I am creating a web interface for OMXPlayer on the Raspberry Pi. I'm trying to create a more REST like API for controlling the video while its playing. The issue I'm having is how to control the video while it is playing. Currently I can create a Player object which...

Connection refused to mosquitto service in Raspian

I installed a fresh and clean new raspbian onto a raspberry pi A+ and added the 1.4.2 mosquitto package from mosquitto.org. With mqtt-gpio-Monitor from https://github.com/sumnerboy12/mqtt-gpio-monitor/issues/3 i try to connect but always get an error saying connection refused. Mosquitto_sub works without issues and connects correctly. The mosquitto service is listening on...

Updating An Image on All instances of a website

So I have a Raspberry Pi controlling my Garage door. The Pi is running an apache webserver. I also have a camera connected to the raspberry pi and I want to be able to update the images from the camera. Currently I have the following code: garage.html: <html> <head> <meta...

Designing a high performance network logger solution for a busy server

I have a highly busy server that keep send/receive massive amount of data through the network, we currently write all the server logs to the same file system where the server is installed and that is causing us to get insufficient disk space after only 1 hour, that file system...

Use same Python variable in multiple if-statements

I am having issues with my current Python script. The purpose of the 'progress' variable is take a specific value when it goes through one of the if-loops. But, the program never goes further then the first if-statement. It looks as if every if-statement makes his own variable called 'progress'....

Raspberry Pi script boot order

There're three forms about running a script on the boot of the Raspberry, that are modifying /etc/rc.local, modifying the cron daemon and making a script that automatically run on boot in /etc/init.d I want to know which of the methods listed about executed first. The point of the question is...

can we open an UDP conection in javascript

I think all is in the title, I want to use socket in js with UDP. I tried with WebSocket but : Uncaught SyntaxError: Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. 'udp' is not allowed. Is it possible with socket.io ? if yes how...

Jumbled out put of RFID Tags

I am working on a project, in which I have to interface multiple RFID Readers (I'm Using EM 18, With Serial out) with Raspberry Pi. I'm using an USB to TTL Converter to connect EM 18 to Raspberry Pi. I've connected two RFID Readers using USB to TTL Adapter. This...

Popen.kill() failing

Update 2: So I piped the output of stderr and it looks like when I include shell=True, i just get the help file for omx player (it lists all the command line switches and such). Is it possible that shell=True might not play nicely with omxplayer? Update: I came across...

How to install shared library and include files manually in linux?

I am trying to build and install TBB library from source so that it can be used for OpenCV to take advantages of multiple cores on my raspberry pi. I was able to build TBB from source without any problems using this steps. (Source : How do I build OpenCV...

Using IPEGA bluetooth gamepad with Retropie

I'm trying to configure my Ipega PG-9025 with Retropie with no succeed. I made some progress following this link (http://askubuntu.com/questions/608386/using-ipega-bluetooth-gamepad-with-steam-linux) but it only works at Emulation Station menu... The gamepad stops working in every emulation system and also gives me some problems pairing and reconnecting my device. Has someone any...

Receive UDP Packets on Google Compute Engine

my task is to receive UDP packets on an Google Compute Engine. Given is the port, which is 300 and I already have a simple Java program which can handle these UDP packets. My problem now. Get the UDP packets to my Java program. For that I don't know how...

Two multicast streams sharing the same group address

I see two different multicast streams with the same group address 226.a.b.c, but different ports A and B, arriving at my machine. I need only one of those (A for example). So I bind my socket to 226.a.b.c:A and do a join request with setsockopt IP_ADD_MEMBERSHIP Now I expect to...

Chrome UDP sockets not receiving from remote machine

I'm working on a Google Chrome app that contains the following code: var socket = chrome.sockets.udp; var PORT = 5005; var HOST = ''; socket.create({}, function(sockInfo){ socket.bind(sockInfo.socketId, HOST, PORT, function(result){ socket.onReceive.addListener(function(info){ // do stuff with the packet data }); }); }); This mechanism worked perfectly when I was sending data...

Are the C functions recvfrom and sendto mutually exclusive?

I have one thread calling recvfrom with a timeout of 100 ms in a loop. Another thread calls sendto periodically. Does the sendto function wait until the recvfrom is released by the timeout (or a successful read) or does it send the data during that period of time....

C# send video frame

I would like to send video frames using UDP connection from the client to server. How do I get the video frame from my webcam? Do I need to save every frame to my computer and from there send it to the server? If i run on 30fps which means...

Read logs from Logcat without killing the tablet

I have to read the logs from Logcat and send them to a server through UDP. For this task I have used this code: https://github.com/chemik/logcatudp The main problem of that code is that the async Thread that is launched enters a while(true) loop that drains the tablet's battery on the...

Access GPIO (/sys/class/gpio) as non-root

The /sys/class/gpio can only be access as root by default. So I like that a new group gpio can use the files and dirs under /sys/class/gpio. To achieve that I added the following lines to /etc/rc.local (I'm on Debian): sudo chown root:gpio /sys/class/gpio/unexport /sys/class/gpio/export sudo chmod 220 /sys/class/gpio/unexport /sys/class/gpio/export So...

c++ UDP socket programming in ubuntu [closed]

I'm trying to learn udp socket programming in c++ but I can't find a useful tutorial and a useful example code . can anybody help me to find some?

Java read bytes from Socket on Linux

I'm trying to send a file from my Windows machine to my Raspberry-Pi 2, and I have a client and a server. The client should be able to send a zip file over the network to my server on my linux machine. I know my client and server work on...

QtDesigner for Raspberry Pi

I am building a UI with QT Designer. I need this UI to run on a Raspberry Pi. What do I need to do to make the UI for the Pi? Does it have to be written in a specific language like python or can I just write it in...

C++ chrono library on Raspberry Pi

On a Raspberry Pi 2, I need to call a php file on a regular basis, typically every 100ms. I found this c++ code which looks like it does what I need and a test version of it compiles and runs fine using CodeBlock on Windows. I've updated the wheezy...

Missing line in “Follow UDP Stream” in wireshark

I am streaming raw UDP packets (rf data) from GNU Radio to Octave (or any other program). The data consists of 390625 4 byte floats per second. This is 1562500 bytes per second. When GNU Radio streams UDP, there is no header or sequence number in the UDP data, it's...

Using macbook pro as display for raspberry pi 2 [closed]

I just received a pi 2 with sd card preloaded with NOOBS. I also have an hdmi cable and wifi dongle for it. I wanted to begin using the pi 2 but do not have a spare monitor to connect it to. I was hoping to be able to connect...

GPS App compile errors

I am working on a GPS application on the Raspberry pi. I have just installed GPSD by running sudo apt-get install gpsd gpsd-clients. I do get data from my GPS module when I run sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock. My issue resides when I try to make my own GPS...

Replace character in string with multiple characters Shell Script

I want to replace "." in this result: "" with " dot ". Here is my code: #!/bin/bash connection=`netstat -tn | grep :1337 | awk '{print $5}' | cut -d: -f1` #this returns "" replace=" dot " final=${connection/./$replace} echo "$final" Which returns: test.sh: 4: test.sh: Bad substitution I tried using...

Raspberry Pi MicroSD Boot not working, MicroSD card unreadable on PC

I downloaded the necessary files for Raspberry Pi onto a MicroSD card, although the MicroSD card is no longer readable. When I put the card into the computer through a MicroSD to USB adapter nothing shows up in Windows Explorer. The card isn't present in Windows Disk Management either. How...

setInterval doesn't get cleared, function keeps getting executed

I have the following function: function monitorClimate() { var sensorReadingInterval; function startClimateMonitoring(interval) { sensorReadingInterval = setInterval(function() { io.emit('sensorReading', { temperature: sensor.getTemp() + 'C', humidity: sensor.getHumidity() + '%' }); }, interval); console.log('Climate control started!'); } function stopClimateMonitoring() { clearInterval(sensorReadingInterval); console.log('Climate control stopped!'); } return { start: startClimateMonitoring, stop: stopClimateMonitoring }; }...

Boost raw sockets

I know it is a very theoretical question, but forgive me as this is not my specialty. Looking for an example on how to use raw sockets with boost, I found a question in this same website where it is assured that you cannot know the destination of an UDP...

Why doesn't “Set-Item” work on Windows 7 PowerShell?

I am trying to install Windows 10 IoT on my Raspberry Pi 2. The PowerShell documentation tells me to put in this: Set-Item WSMan:\localhost\Client\TrustedHosts -Value <minwinpc> However, when I put it into my Windows 7 PowerShell, this comes out: At line:1 char:54 + Set-Item WSMan:\localhost\Client\TrustedHosts -Value <minwinpc> + ~ The...

what will be done if the buffer socket full

what will be done if the buffer socket full in an UDP protocol? does it replace the old data with the new one? ot it just drop the new data? In case that it's not related with UDP protocols, and it's specified in the code, how to do this in...

Cross compiling for Raspberry pi 2 error

I wanted to start cross compiling for raspberry pi2 on Ubuntu 32bit (in virtual box), so I downloaded the toolchain on the github site (https://github.com/raspberrypi/tools) and tried to compile a simple hello world program with the command (I've included the path to the bin folder that contains arm-linux-gnueabihf-gcc-4.8.3 to the...

With Java DatagramSockets, can I connect two different sockets to the same local port but on different local addresses?

With Java DatagramSockets, can I connect two different sockets to the same local port but on two different local addresses? I have this situation. My computer has a WiFi card and an ethernet cable connected. The Wifi and the Ethernet are both working and they have two different addresses (""...

how to spoof outgoing UDP socket port number in linux?

The question is the title. But I'd like to describe my problem so that someone can suggest an alternative solution. I know that when the client sends a message on a socket to, the router on the client's side sets a rule for some time that any data received...

How to install RPi.GPIO to windows

I have looked and most of the tutorials are rasbian based. I would like it on windows so I can develop a python script on windows to which would later be put on the Raspberry pi. I have downloaded the module and have tried python setup.py install in command prompt...

UDP and TCP always use same IP for one client?

I've made a server (python, twisted) for my online game. Started with TCP, then later added constant updates with UDP (saw a big speed improvement). But now, I need to connect each UDP socket client with each TCP client. I'm doing this by having each client first connect to the...

Golang UDP Server only recieving locally sent packets

I've written a UDP Server in Go(listens on port 666), and it seems to be only receiving packets that were sent locally. To confirm traffic, I have been using: sudo tcpdump -n udp dst port 666 My(abbreviated) server code: import "net" func startServer() { // Bind the port. ServerAddr, err...

The meaning of Java's DatagramChannel.write()

I recently found code using DatagramChannel.write(). The code only asked for host ip and port before it connected and then would allow sending (via DatagramChannel.write()). Being new to network programming, it seemed odd that it wouldn't request the destination IP/port. Why not? Oracle's documentation states This method may only be...