I am working on a project to build a robot using raspberry pi that will send video to android device, and will be controlled from it.
I decided to use the RaspberryPi camera (maybe usb webcam is better?).
I want the video to be in H264 format, but I got problem in getting streaming in this kind of format.
I tried using gstreamer and vlc:
On the RaspberryPi:
raspivid -t 999999 -h 720 -w 1080 -fps 25 -hf -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.1.102 port=5000
On my PC (to view the video):
gst-launch-1.0 -v tcpclientsrc host=192.168.1.102 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false
So first, my question is if there is any way to set a url to catch this gstreamer stream (or any other way to catch the stream in the android app code)?
Second, If you have any other advices, such as using a different camera, different format (not mjpg), different streaming way, etc.
The way you have chosen is the best one I believe. Gstreamer has android examples ready to use (via NDK): http://docs.gstreamer.com/display/GstSDK/Android+tutorial+3%3A+Video
You can find sample application here: https://play.google.com/store/apps/details?id=pl.effisoft.rpicamviewer2
Sure, you can use that same PC pipeline in Android code. Take a look at GStreamer's Android Tutorial 3 to see how to run GStreamer code on Android. You can basically run that exact tutorial program on your Android device, just paste your pipeline into call to gst_parse_launch
. Also, make sure to add the INTERNET permission to your Android manifest, otherwise your program won't be able to open up a socket.
The only thing is that your pipeline is using GStreamer 1.0, while the SDK tutorial example above is written for GStreamer 0.10. It's fairly easy to cross compile the GStreamer 1.0 SDK for Android using the Cerbero build system though (I have done this recently and can help you out). Or you can just stick with 0.10 on Android and use the pre-built 0.10 SDK files.
EDIT: One more thing -- you don't need both the RTP payloader and the GDP payloader, just one. RTP alone works well for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With