Streaming raspi camera video to Tower video widget

3689691896?profile=originalI am reporting how to stream Raspberry pi camera video to Tower video widget. 

On the last weekend, I attended a drone meeting. I brought my IRIS which was given from my friend. It flew well and I was very satisfied with my first flight. In the meeting, other people brought their brand new drones like SOLO,  Phantom, and Inspire. I had a chance to fly them and I felt something was missing in my old IRIS. It was FPV! I live in Japan and because of a regulation, we can't use a 5.8GHz video transmitter without a licence. Furthermore, SOLO costs twice as in USA. However, I noticed a video widget(small screen) in Android "Tower" app and it was said that it receive custom video streaming.   In that article, the author used Ubuntu as the source. Since I had a raspberry pi 2 with pi camera, I had tried to use it as a FPV camera server. The followings are how to set up video streaming. I hope it will work with your environment.

1. Set up raspberry pi for streaming video

From the shell type the commands in the following post or clone a repo. to execute the srcript

Install gstreamer and enable hardware h264 encoding with gstreamer on the Raspberry Pi

2. Enable a camera module

Type

$ sudo raspi-config

From the menu, Select "Enable camera" and then select "Enable".

If you already did it. You can move to the next step.

3. Start streaming

$ raspivid -n -t 0 -w 640 -h 360 -fps 24 -b 6000000 -o - | gst-launch-1.0 -e -vvvv fdsrc ! h264parse ! rtph264pay pt=96 config-interval=5 ! udpsink host=192.168.3.11 port=9000

You should configure an address of the host and port. The address is the clients(an android tablet)' IP address. You can change port number. You can change the resolution of the video -w: wide -h: height. There are so many parameters to control the video format.

4. Show video on Tower widget

Please follow the instruction here.

You need to set the port number as same as the one specified above.

You only have video while connecting to your pixhawk. 

Now you can watch a flight data and video footage on a same screen as the latest drones!

On Wifi network, latency was not unbearable. I hope to install a raspi on my IRIS soon.

In a future, I would like to use 4G/LTE network for telemetry and video streaming. 

note: The current supply of the usb ports of a raspberry pi is limited. It is better to supply external power to wifi or 4G/LTE usb dongle or the system may hang up soon or later.

You may need to install rpicamsrc

Thanks!

 

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Hello,

    I have build a RPI Zero autopilot (see link below) and just upgraded to RPI Zero + Camera. The processor is running at80% (60% Arducopter + 8 & gstreamer + 4% raspivid) , I hade to reduce the resolution and fps to keep some resources so it does not get unstable or just hang.

    After many many test, it is quite clear now that my Android tablet : ACER Iconia One 7,  cannot run both Tower and the video feed more than 5 minutes without loosing connection... :-( .  I reduced the resolution to 320 x 200 at 15 fps and it is still struggling to get both mavlink & video stream together. If I divert the video to another device , it is OK. So I need to double check with a bigger android unit.

    Anyone experienced this ?

    This is the link for my build, the MINI-Zee:

    http://diydrones.com/profiles/blogs/mini-zee-a-100-diy-smart-drone-...

  • @Matthias Do you mean you just want to save the encoded h264 to a file?  If so, it should be straight forward, just drop the h264pay and direct to filesink through a muxer instead:

    gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720,framerate=30/1 ! jpegparse ! jpegdec ! queue ! videoconvert ! omxh264enc ! h264parse ! avimux ! filesink location='funstuff.avi'

     or

    gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720,framerate=30/1 ! jpegparse ! jpegdec ! queue ! videoconvert ! omxh264enc ! h264parse ! mpegtsmux ! filesink location='funstuff.mp4'

  • @Fnoop Do you even know a command to record the raw file decoded to h264 to a file?
  • Dear Fredia. Thanks a lot! 

  • @Kaizu, I went ahead and create a wiki entry linking to your blog post. Feel free to take a look and let me know if you have any comments/suggestions: https://github.com/DroidPlanner/Tower/wiki/Streaming-raspi-camera-v...

    Thanks!

    DroidPlanner/Tower
    Ground Control Station for Android Devices. Contribute to DroidPlanner/Tower development by creating an account on GitHub.
  • Great, not often I get to help other people :)

  • @Fnoop Thank you!!! Its working with the "raw" command (i have a usb uvc grabber). You helped me a lot 

  • hi friends i buyed cuav mobile video receiver to see the video for tower app but i dont know how to setup.pls help i select UDP  then its ask UDP server port and UDP ping recevier ip how to find it in my android mobile, i attached below the image...waiting for ur reply friends..3702249361?profile=original

  • @Matthias, sure you can use any v4l2 device.  It depends on the capability of the camera, so if it outputs h264 just do something like:

    gst-launch-1.0 v4l2src device=/dev/video0 ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=192.168.1.10 port=5000

    If it only outputs raw or mjpeg, then do something like this for mjpeg:

    gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720,framerate=30/1 ! jpegparse ! jpegdec ! queue ! videoconvert ! omxh264enc ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=192.168.1.10 port=5000

    It works similarly for raw, just alter the caps and remove the jpeg elements.  You can also process h264 from the raspberry camera in the same way, although the current gstreamer that comes with the current raspbian is broken.

  • Hi, is it possibble to use a UVC device (/dev/video0) instead of rapicam? How to change the gstream-command to get the this working?

    fliegermati

This reply was deleted.