简体   繁体   中英

How to stream H264 with gstreamer?

I need to stream my screen in fullHD, to my android phone with gstreamer, using H264. I'm using gst launch remote on Android and gst-launch on linux.

I'm starting with gstreamer, I managed to do basic stream following this tutorial , but anything a bit different from the examples crashes on various ways.

My basic pipeline is:

ximagesrc use-damage=false xname=/usr/lib/torcs/torcs-bin ! videoconvert ! x264enc tune=zerolatency ! rtph264pay ! udpsink host=192.168.0.100 port=5000

And:

udpsrc port=5000 caps=$CAPS ! rtph264depay ! avdec_h264 ! autovideosink

I tied to copy the caps from the first pipeline (all or multiple combinations of isolated parameters) to $CAPS but didn't work.

With

caps="video/x-h264\,\ codec_data\=\(buffer\)01f40028ffe1001a67f400289196401e0089f89c0440000003004000000ca3c60c9201000668ebcc448440\,\ stream-format\=\(string\)avc\,\ alignment\=\(string\)au\,\ level\=\(string\)4\,\ profile\=\(string\)high-4:4:4\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ framerate\=\(fraction\)25/1"

the pipeline isn't constructed, the only error is:

WARNING: erroneous pipeline: could not link udpsrc0 to rtph264depay0

Or with caps

application/x-rtp\,\ media\=\(string\)video\,\ clock-rate\=\(int\)90000\,\ encoding-name\=\(string\)H264\,\ packetization-mode\=\(string\)1\,\ payload\=\(int\)96\,\ a-framerate\=\(string\)25

The error is:

ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data flow error.

Error message witout caps:

Setting pipeline to PAUSED ...
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
Pipeline is live and does not need PREROLL ...
Got context from element 'autovideosink0': gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)NULL;
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0: No RTP format was negotiated.
Additional debug info:
gstrtpbasedepayload.c(484): gst_rtp_base_depayload_handle_buffer (): /GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0:
Input buffers need to have RTP caps set on them. This is usually achieved by setting the 'caps' property of the upstream source element (often udpsrc or appsrc), or by putting a capsfilter element before the depayloader and setting the 'caps' property on that. Also see http://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/gst/rtp/README
Execution ended after 0:00:00.006279687
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Changing the source video from a web solved the caps negotiation issue. The final pipeline was:

v4l2src ! videoscale ! video/x-raw,width=1600,height=1150 ! x264enc tune=zerolatency ! rtph264pay ! udpsink host=192.168.0.100 port=5000

And:

udpsrc port=5000 caps = "application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, payload=96" ! rtph264depay ! avdec_h264 ! autovideosink

Thought, bigger resolutions are crashing the app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM