tobertinker
Posts: 5
Joined: Sun Jun 02, 2013 7:09 pm

trouble streaming video from raspberry pi to raspberry pi

Sun Jun 02, 2013 7:26 pm

Hi,

I am trying to stream video from one raspberry pi to another. I am following the directions posted at http://www.raspberrypi.org/archives/tag/camera-board.

My trouble seems to be occurring on the receiving end. My first question is when I type the command mkfifo buffer, what directory should I be in?

I went ahead and make one in the pi folder and the opt.vc/src/hello_pi/hello_video folder and tried to run the next command:

nc -p 5001 -l > buffer | /opt.vc/src/hello_pi/hello_video/hello/video.bin

The error it gave me at first was that there was no file or directory, and I checked and there was no hello_video.bin, so I did mkfifo hello_video.bin to create one.

Then I got the following error:
bash: /opt/vc/src/hello_pi/hello_video/hello_video.bin: Permission denied


I tried putting sudo in front of the /opt and another time infront of buffer for my command along with running the command in root terminal and it still gave me the same error. Could someone point out where my problem is? Should I be using another method?

My application for sending the video is to have one pi on a robot with the camera sending the video to another pi

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: trouble streaming video from raspberry pi to raspberry p

Mon Jun 03, 2013 7:38 am

Your problem appears to be that you haven't compiled the /opt/vc/src/hello_pi/hello_video/hello/video.bin program

Have a look at the /opt/vc/src/hello_pi/README file for instructions on how to compile it.

The buffer file can be created in any directory that you have permission to. Just create it in the /home/pi/ directory

tobertinker
Posts: 5
Joined: Sun Jun 02, 2013 7:09 pm

Re: trouble streaming video from raspberry pi to raspberry p

Mon Jun 03, 2013 10:51 pm

Thank you!

I followed the readme instructions and I no longer get the permissions error.

When I execute the nc -p 5001 -l > buffer | /opt/vc/src/hello_pi/hello_video/hello_video.bin buffer command it appears to running, but there is no video or even words like "buffering "10%" or something like that. I had tried to follow the linux instructions and I did get text like Playing - Reading from stin Cache fill: x% (x bytes).

Should I be getting text like that when I run the command with the buffer?

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: trouble streaming video from raspberry pi to raspberry p

Tue Jun 04, 2013 2:49 am

tobertinker wrote:Thank you!

I followed the readme instructions and I no longer get the permissions error.

When I execute the nc -p 5001 -l > buffer | /opt/vc/src/hello_pi/hello_video/hello_video.bin buffer command it appears to running, but there is no video or even words like "buffering "10%" or something like that. I had tried to follow the linux instructions and I did get text like Playing - Reading from stin Cache fill: x% (x bytes).

Should I be getting text like that when I run the command with the buffer?
See this thread. It might help: http://www.raspberrypi.org/phpBB3/viewt ... 17#p352717

tobertinker
Posts: 5
Joined: Sun Jun 02, 2013 7:09 pm

Re: trouble streaming video from raspberry pi to raspberry p

Sat Jun 08, 2013 12:05 am

I looked at the forum and copied your command :

raspivid -t 999999 -o - | nc 192.168.1.87 5001

into the terminal, with the receiver having its command of

nc -p 5001 -l > buffer | /opt/vc/src/hello_pi/hello_video/hello_video.bin buffer

All of which there was no en-dashes. The camera board turned on for a few seconds, and then froze. The receiving pi did nothing, but the camera board did start! I feel I am close, but I must be doing some small error that I can't find. Any ideas? Thanks

tvjon
Posts: 713
Joined: Mon Jan 07, 2013 9:11 am

Re: trouble streaming video from raspberry pi to raspberry p

Sat Jun 08, 2013 8:00 am

tobertinker wrote:......
into the terminal, with the receiver having its command of

nc -p 5001 -l > buffer | /opt/vc/src/hello_pi/hello_video/hello_video.bin buffer

.. The camera board turned on for a few seconds, and then froze. The receiving pi did nothing, but the camera board did start! I feel I am close, but I must be doing some small error that I can't find. Any ideas? Thanks
The "freezing" is because the listener is no longer (ever has?) accepting your stream.

You could try this as I posted in another thread.

nc -l -k 5001 | ./hello_video.bin /dev/stdin

ensuring you start the receiver first.

HTH

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: trouble streaming video from raspberry pi to raspberry p

Sat Jun 08, 2013 8:31 am

Also double check that 192.168.1.87 is the IP address of the receiving Pi.

itimpi
Posts: 1090
Joined: Sun Sep 25, 2011 11:44 am
Location: Potters Bar, United Kingdom
Contact: Website

Re: trouble streaming video from raspberry pi to raspberry p

Sat Jun 08, 2013 5:42 pm

Another thing that can cause problems if you are using WiFi on your pi's is that many routers stop two Wifi clients communicating with each other. It is worth checking with a ping command on one of the pi's that it can see the other one across the network.

tobertinker
Posts: 5
Joined: Sun Jun 02, 2013 7:09 pm

Re: trouble streaming video from raspberry pi to raspberry p

Mon Jun 10, 2013 2:27 am

Thanks for the replies,

I have tried tvjon's suggestion and used nc -l -k 5001 | ./hello_video.bin /dev/stdin. unfortunately this is what I got, servname not supported for ai_socktype:

root@raspberrypi:/opt/vc/src/hello_pi/hello_video# nc -l -k 5001 ./hello_video.bin /dev/stdin
nc: getaddrinfo: Servname not supported for ai_socktype

I also tried it the default pi directory, but I got the same error

root@raspberrypi:/home/pi# nc -l -k 5001 ./hello_video.bin /dev/stdin
nc: getaddrinfo: Servname not supported for ai_socktype

Am I doing something wrong?


I was using the correct IP address, I was just copying the example from fbultler's code because when I had typed the question I had already turned the other pi off and forgot the IP address. Thanks for the suggestion though.

I also did the pin command and got time of 300-500ms, so I don't thing it was super bad:

I noticed though when I ran the command to send the video (raspivid -t 999999 -o - | nc [ip address] 5001nstead of the video freezing on the sending pi, it would only appear for a just a split second and then quit. The command line gave no errors. The recieving pi whose command I gave

root@raspberrypi:/home/pi# nc -p 5001 -l > buffer | /opt/vc/src/hello_pi/hello_video/hello_video.bin buffer

did nothing, I could tell it was running something. It did not give me errors. So I eventually had to stop the command by using Control + 'c'.

Since the video recording stopped abruptly does that mean the problem is with the sending pi? Thanks again for all the help.

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: trouble streaming video from raspberry pi to raspberry p

Mon Jun 10, 2013 8:42 am

tobertinker wrote: Since the video recording stopped abruptly does that mean the problem is with the sending pi? Thanks again for all the help.
No, that just means it gave up because it couldn't connect to the receiving Pi. That's why you run the command on the receiving Pi first. The command on the receiving Pi sits and waits for data to be received from the sending Pi. Then when you start the command on the sending Pi it should send data to the receiving Pi and everything should work. That's why I said to check that you were using the correct IP address for the receiving Pi.

I noticed that you are running the commands as root. Have you tried running them as the Pi user having run the mkfifo buffer command as Pi as well?

tobertinker
Posts: 5
Joined: Sun Jun 02, 2013 7:09 pm

Re: trouble streaming video from raspberry pi to raspberry p

Mon Jul 15, 2013 3:04 am

I finally figured it out! I was running my pis in a computer lab at my university and the wifi there is protected, and all students have to sign in on devices to use the internet. The pi's never picked up the sign in, so the pi would briefly connect, get an ip address, get booted off, and then connect to another access point!

So my solution was an ad hoc wifi connection! It works great, I am using the wipi dongles that I had got from Newark. I have about a 1.5 to 2 second delay though and I tried lowering the frame rate, but that did not help much.

Is there a way I can drop the frames at the beginning and not have a buffer of some sort so I can have no delay. I have seen on the forums on ways that can get it to 1 second, but I would really like it to be less than a quarter of second for my application.

Thanks again for all your help and suggestions!

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24115
Joined: Sat Jul 30, 2011 7:41 pm

Re: trouble streaming video from raspberry pi to raspberry p

Mon Jul 15, 2013 7:40 am

tobertinker wrote:I finally figured it out! I was running my pis in a computer lab at my university and the wifi there is protected, and all students have to sign in on devices to use the internet. The pi's never picked up the sign in, so the pi would briefly connect, get an ip address, get booted off, and then connect to another access point!

So my solution was an ad hoc wifi connection! It works great, I am using the wipi dongles that I had got from Newark. I have about a 1.5 to 2 second delay though and I tried lowering the frame rate, but that did not help much.

Is there a way I can drop the frames at the beginning and not have a buffer of some sort so I can have no delay. I have seen on the forums on ways that can get it to 1 second, but I would really like it to be less than a quarter of second for my application.

Thanks again for all your help and suggestions!
Some of that delay is probably the wireless networking itself. When streaming over wired ethernet from Pi to desktop I see almost no delay. Have you tried it wired to see what the delay is?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

Return to “Camera board”