ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

Re-stream video capture

asked 2014-01-20 20:24:03 -0500

Andrew.A gravatar image

updated 2014-01-21 14:12:29 -0500

I currently have a robot running Ubuntu with ROS installed and an Asus Xtion Pro Live attached. What I'm trying to do is to capture the video and push it to a server, and then have the server re-stream it so that other clients that connect to my server can view the stream. The server is running Windows, has a public ip and does not have ROS installed.

What I currently have now is, while the robot is on the same wifi as a client, use mjpeg_server, and have the client connect directly to the robot to view the stream. What I'm trying to overcome is, if I wanted to use my robot outside and use a 3G/4G dongle, I wouldn't be able to connect to it directly. Or, if I wanted to view the video stream from outside the network. So I want it to push the stream to my server, and then have clients connect to the server to view the stream through a webapp. The server currently runs a webapp on tomcat, using java, javascript jsp, jquery, mssql. I want to add on to the webapp to allow viewing the video stream from the Asus Xtion on my robot, without having to install ROS on the server if possible.

I roughly know that there will be three things I have to do:

  1. Stream the Asus Xtion camera feed to the server,
  2. Receive the stream on my server somehow, and
  3. Have my server re-stream the video.

But I don't really have any idea on how to go about doing this. Can anyone help?

EDIT: I know that with VLC, I can pull a video stream, and then re-stream it. However this won't work for me because I won't be able to pull from the robot; it doesn't have a public ip so it wouldn't be accessible.

edit retag flag offensive close merge delete

Comments

It seems like this is unrelated to ROS, where would you want to fit ROS in? If you just need a rough implementation, it is possible to stream on OpenCV matrix over TCP/UDP sockets, but don't expect excellent performance for the resolution of the Xtion. If you need more fidelity I'd use videolan.org

Tim Sweet gravatar image Tim Sweet  ( 2014-01-21 06:25:51 -0500 )edit

It doesn't necessarily have to use ROS, but I was thinking perhaps I could use ROS to get the stream produced by mjpeg_server, and then push it out to the server.

Andrew.A gravatar image Andrew.A  ( 2014-01-21 14:06:18 -0500 )edit

Also, as far as I know, VLC can only pull a video stream, and then re-stream it. This isn't possible for me because the robot doesn't have a public IP, as I've mentioned I'll be using 3G or 4G. I've also stated in my question that I need to *push* to the server, not pull from the server.

Andrew.A gravatar image Andrew.A  ( 2014-01-21 14:08:31 -0500 )edit

The mjpeg_server package is serving the OpenCV matrix over TCP, so you could try it. To solve the public IP problem I'd suggest using openvpn (openvpn.net). Either way your going to have terrible quality and latency over 3G/4G, so I would do some processing on the robot to reduce the data size.

Tim Sweet gravatar image Tim Sweet  ( 2014-01-22 16:42:08 -0500 )edit

I do not want clients connecting directly to the robot, because its specs are quite weak. I want the robot to push the stream to the server, and then have clients connect to that server instead. Do you know how I can do this?

Andrew.A gravatar image Andrew.A  ( 2014-01-22 19:23:02 -0500 )edit

I'm trying to say your results over 3G/4G are going to be very poor, likely in the order of a frame every few seconds, plus lag of a few seconds. But if you set up openvpn on the robot and server you will be able to use mjpeg_server to do exactly that.

Tim Sweet gravatar image Tim Sweet  ( 2014-01-22 20:27:46 -0500 )edit

You could implement it directly by serializing each image (using opencv) over a TCP socket. The server would open a port for listening, and the robot would connect to it and send the image, and the server would deserialize it. That would avoid openvpn assuming the server has a public IP

Tim Sweet gravatar image Tim Sweet  ( 2014-01-22 20:30:17 -0500 )edit

Could you perhaps write an answer with more details on doing this? I get that the results over 3G/4G might be poor, but where does openvpn come in? How will this help? Also, in your second comment, would that mean writing my own ROS package to do the serializing? Lastly, server already has public ip

Andrew.A gravatar image Andrew.A  ( 2014-01-22 21:03:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-01-24 20:39:40 -0500

updated 2014-01-25 06:27:38 -0500

Okay here we go:

To clarify, this is what I believe your setup is:

  • Robot has ROS installed and has a cellular (3G/4G) dongle. It has a camera on board and you need to stream the image to multiple computers on a different network.
  • Server is publicly addressable (ie it has open ports on the internet, and you have the authority to open those ports). It does not have ROS installed. It will get the image from the robot's camera and make it publicly available. I will assume the server runs Ubuntu, you could adapt the commands below for Windows
  • Multiple clients do not have anything special installed, and need to view the camera stream.

On the cellular thing: I really think you'll get less than one frame per second with this setup.

Anyway, here is how I would set this up:

  1. On the server, open UDP port 1194 to the internet
  2. On the server, install OpenVPN with: sudo apt-get install openvpn
  3. Update: these directions are more accurate: Follow the instructions at: https://github.com/OpenVPN/easy-rsa/blob/master/README.quickstart.md to generate a server key and client key (note you'll need to git easyrsa onto both machines from https://github.com/OpenVPN/easy-rsa). Put the keys and certificates you generate into the /etc/openvpn/ directory on each machine
  4. On the server, copy the server configuration file at http://openvpn.net/index.php/open-source/documentation/howto.html#server to a new file at: /etc/openvpn/server.conf
  5. On the server, update the ca cert key and dh fields in server.conf to match the keys you generated in step 2
  6. On the robot, download OpenVPN with: sudo apt-get install openvpn
  7. On the robot, copy the client configuration file at http://openvpn.net/index.php/open-source/documentation/howto.html#client to /etc/openvpn/client.conf
  8. In that client.conf file, change "my-server" in the line remote my-server-1 1194 to the public IP address of your server.
  9. On both the server and robot run: sudo service openvpn restart to have them both connect through the VPN tunnel.
  10. To test the configuration: on the robot, ping the server with: ping 10.8.0.1, then on the server ping the robot with: ping 10.8.0.6. If one of these fails, let me know and we'll debug it.
  11. On the server, install mjpeg_server with sudo apt-get install ros-hydro-mjpeg-server
  12. Set up mjpeg_server to start streaming (I've never used it...but let me know if you have problems and we can take a look together). I'll continue under the assumption this is working and you can view the image by going to http://localhost:8080/stream?topic=/IMAGE_TOPIC
  13. On the server, go to: http://10.8.0.6:8080/stream?topic=/IMAGE_TOPIC and you should see the images. I'd suggest trialing this over Ethernet or WiFi before trying to use the cellular adapter

From here I assume you can figure out the streaming to clients ... (more)

edit flag offensive delete link more

Comments

My server is running Windows though. Would this mean a big change in your solution? I'll follow what I can and ask you once I get stuck.

Andrew.A gravatar image Andrew.A  ( 2014-01-26 14:30:22 -0500 )edit

Also, for point 11, do you mean to install mjpeg_server on the robot? Because I haven't got ROS installed on my Windows server.

Andrew.A gravatar image Andrew.A  ( 2014-01-26 15:34:30 -0500 )edit

I've managed to setup openvpn on Windows. Just some small changes: the server file is `server.ovpn`, the keys and server config file should be placed in the config dir `C:\Program files\OpenVPN\config`. Setting up on the robot now...

Andrew.A gravatar image Andrew.A  ( 2014-01-28 13:52:03 -0500 )edit

I'm having some trouble creating the tunnel, I think. I can't ping from server to client and vice versa. However, on the Windows server, I can `ping 10.8.0.1` and get a response. On the robot, I can't `ping 10.8.0.6`; there's no response at all. Seems like there's some problem on the client side.

Andrew.A gravatar image Andrew.A  ( 2014-01-28 14:43:13 -0500 )edit

I'm getting some error, require nsCertType=Server. Full output here: http://pastebin.com/s9uUR5nk thanks

Andrew.A gravatar image Andrew.A  ( 2014-01-28 15:32:50 -0500 )edit

Okay I managed to fix the error. I had to replace the `ns-cert-type server` line in client.conf with `remote-cert-tls server`. But now I'm getting another error about operation not permitted, and some error getting interface flags: no such device. Full output at http://pastebin.com/ZgwUB9Ve thanks

Andrew.A gravatar image Andrew.A  ( 2014-02-04 13:38:45 -0500 )edit

Okay it was a simple problem. I just had to be root to do it. Everything seems fine and should be working right now... but I can't ping from server to client, or client to server. Each can ping themselves though. Dyou know what's wrong?

Andrew.A gravatar image Andrew.A  ( 2014-02-04 14:35:33 -0500 )edit

Forgot to add the step here. Just needed to run the windows OpenVPN GUI as administrator, then everything worked. Thanks!

Andrew.A gravatar image Andrew.A  ( 2014-02-16 18:32:26 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-01-20 20:24:03 -0500

Seen: 2,449 times

Last updated: Jan 25 '14