H264 Streaming Using RaspberryPi Camera

I am working on a project to create a robot using raspberries pi, which will send video to an Android device and will be controlled from it.
I decided to use a RaspberryPi camera (maybe a USB webcam is better?). I want the video to be in H264 format, but I have a problem with streaming in this format. I tried using gstreamer and vlc:

  • If I use vlc, I get a very delayed video, not smooth.
  • If I use gstreamer, I get a good video, but I do not know how to set the URL to add the Android application code. I see a video by running the gstreamer command on my computer. I use the following commands:

On 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 watch the video):

 gst-launch-1.0 -v tcpclientsrc host=192.168.1.102 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false 

So firstly, my question is, is there a way to set the url to catch this gstreamer stream (or any other way to catch the stream in the Android application code)?
Secondly, if you have other tips, for example, using a different camera, a different format (not mpg), a different stream, etc.

+7
stream video-streaming gstreamer raspberry-pi
source share
4 answers

The way you chose is the best that I believe in. Gstreamer has Android examples ready for use (via NDK): http://docs.gstreamer.com/display/GstSDK/Android+tutorial+3%3A+Video

Here you can find an example application: https://play.google.com/store/apps/details?id=pl.effisoft.rpicamviewer2

+1
source share

Of course, you can use the same PC pipeline in Android code. Take a look at the GStreamer Android Tutorial 3 to learn how to run the GStreamer code on Android. Basically you can run this exact tutorial on your Android device, just insert your pipeline into the gst_parse_launch call. In addition, do not forget to add the Internet permission to your Android manifest, otherwise your program will not be able to open the socket.

The only thing is that your pipeline uses GStreamer 1.0, and the sample SDK tutorial above is written for GStreamer 0.10. It's pretty easy to compile the GStreamer 1.0 SDK for Android using the Cerbero build system (I did this recently and can help you). Or you can just stick with 0.10 on Android and use the pre-created 0.10 SDK files.

EDIT: One more thing - you don’t need both the RTP mail downloader and the GDP payment downloader, just one. Only RTP works well for me.

+1
source share

You can find a possible solution from the RTSP Streaming H264 forum.

Access to the rasperry camera board is possible through the V4L2 driver:

 sudo modprobe bcm2835-v4l2 

uv4l --driver raspicam --auto-video_nr

Next, you can find a simple implementation of the RTSP streamer cors from the source H264 V4L2 gihub

+1
source share

Compiling gstreamer for Android can be complicated. You may consider an alternative solution for viewing your pipeline on an Android device. The sample code below opens a simple pipeline based on videotestsrc:

 Intent intent = new Intent("pl.effisoft.rpicamviewer2.PREVIEW"); int camera =0; //--------- Basic settings intent.putExtra("full_screen", true); intent.putExtra("name"+camera, "My pipeline name"); intent.putExtra("host"+camera, "192.168.0.1"); intent.putExtra("port"+camera, 5000); intent.putExtra("description"+camera, "My pipeline description"); intent.putExtra("uuid"+camera, UUID.randomUUID().toString() ); intent.putExtra("aspectRatio"+camera, 1.6); intent.putExtra("autoplay"+camera, true); //--------- Enable advanced mode intent.putExtra("advanced"+camera, true); intent.putExtra("custom_pipeline"+camera, "videotestsrc ! warptv ! autovideosink"); //--------- Enable application extra features intent.putExtra("extraFeaturesEnabled"+camera, false); //--------- Add autoaudiosink to featured pipeline intent.putExtra("extraFeaturesSoundEnabled"+camera, false); //--------- Scale Video Stream option intent.putExtra("extraResizeVideoEnabled"+camera, false); intent.setPackage("pl.effisoft.rpicamviewer2"); startActivityForResult(intent, 0); 

Full code example here: https://github.com/pzuk/raspberry-pi-camera-viewer-embedded-example

+1
source share

All Articles