Page 1 of 1

Raspivid UDP streaming

Posted: Fri Mar 24, 2017 11:24 pm
by Bluebird
Good day everybody,

For my project i need a Raspberry Pi (running Arch Linux) streaming video to a Windows 10 pc.
As a test i have both Raspberry Pi & Windows 10 pc on the same network (in future they will be connected directly through a network cable).

On the Raspberry Pi i can get the camera working, but the stream via UDP won't, at least i can't read the UDP signal.
On my Raspberry Pi i use this:

Code: Select all

/opt/vc/bin/raspivid -n -t 0 -fps 30 -w 800 -h 600 -o - | nc -u 192.168.248.128 1900
The IP address (192.168.248.128) is the IP address from the computer i try streaming too. When i run the command, the Raspberry Pi keeps running it (with no output). If i use the IP address from the raspberry itself, it quits immideately without an output.

On my windows 10 system i try using code or even VLC player to connect to: udp://192.168.248.128:1900 but none of them can connect.

In C++ code i try this:

Code: Select all

#include "opencv2/opencv.hpp"
#include <stdint.h>

using namespace cv;
using namespace std;

int main(int argv, char** argc)
{
	Mat frame;

	VideoCapture vid;
	vid.open("udp://@192.168.248.128:1900");



	if (!vid.isOpened()) {
		return -1;
	}

	while (vid.read(frame)) {
		imshow("Stream", frame);
		
		if (waitKey(1000 / 30) >= 0) {
			break;
		}
	}
	return 1;
}
Here i get the next error on the vid.open("udp://...."); command:
vid = <Information not available, no symbols loaded for opencv_world320d.dll>
and
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:779)
warning: udp://@192.168.248.128:1900 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:780)
What am i doing wrong?
Btw, i am using netcat


Thanks for your help!

Re: Raspivid UDP streaming

Posted: Sat Mar 25, 2017 12:21 pm
by KnarfB
Hi, for me the following works:
on the RasPi (current Raspbian Jessie):

Code: Select all

raspivid -t 0 -b 2000000 -fps 30 -w 800 -h 600 -o - | nc -p 1904 -u 192.168.2.108 1234
on the Ubuntu client, start vlc from command line:

Code: Select all

vlc -vvv udp://@:1234 :demux=h264
hth
Frank

Re: Raspivid UDP streaming

Posted: Sat Mar 25, 2017 1:10 pm
by Bluebird
Thank you,
If i try that the Raspberry Pi shows the camera view (realtime).

If i connect to the ip address nothing happens and it shuts down after a few seconds (the programm).

I assume 192.168.2.108 is your ip address from the ubuntu client?

I use my windows pc's ip address but none of these work:

Code: Select all

	vid.open("udp://@192.168.2.248:1234 :demux=h264");
	vid.open("udp://@:1234 :demux=h264");
	vid.open("udp://:1234 :demux=h264");
	vid.open("udp://:1234");
This should work too right?

Thank you!

Re: Raspivid UDP streaming

Posted: Sun Mar 26, 2017 8:58 am
by KnarfB
Hi, try this: "udp/h264://@:1234/", see https://wiki.videolan.org/MRL/.
This works for VLC, but it seems you are using OpenCV.
Try RTSP
on the RasPi: raspivid -t 0 -n -b 1000000 -w 640 -h 480 -fps 30 -o - | cvlc -v stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
and on the client: rtsp://192.168.2.104:8554/
Frank

Re: Raspivid UDP streaming

Posted: Sun Mar 26, 2017 12:51 pm
by Bluebird
Thank you but i am not getting this to work.

If i start your command i get the next errors:

pi@raspberrypi:~ $ sudo raspivid -t 0 -n -b 1000000 -w 640 -h 480 -fps 30 -o - | cvlc -v stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
VLC media player 2.2.4 Weatherwax (revision 2.2.3-37-g888b7e89)
[01690fb0] pulse audio output error: PulseAudio server connection failure: Connection refused
[01691160] core interface error: no suitable interface module
[015f7b28] core libvlc error: interface "globalhotkeys,none" initialization failed
[01691160] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[01691160] core interface error: no suitable interface module
[015f7b28] core libvlc error: interface "dbus,none" initialization failed
[01691160] dummy interface: using the dummy interface module...
[73d00508] core input error: Invalid PCR value in ES_OUT_SET_(GROUP_)PCR !
I have installed vlc on the raspberry pi, and i try with and without sudo. Both give the same errors

Re: Raspivid UDP streaming

Posted: Sun Mar 26, 2017 1:22 pm
by KnarfB
Hi, these errors don't matter. Some are because there is no audio source (PulseAudio) others because you don't use X windows (or, at least the DISPLAY variable is not set). As long as cvlc starts, it's smart enough to work around these. I'm using Raspian and login via ssh -X pi@192.168.2.104, so I'm getting less output:

Code: Select all

[00855658] pulse audio output error: PulseAudio server connection failure: Connection refused
[00724d48] dummy interface: using the dummy interface module...
[74300ed8] core input error: Invalid PCR value in ES_OUT_SET_(GROUP_)PCR !
Here is some related stuff:http://www.raspberry-projects.com/pi/pi ... vlc-player
hth
Frank