title: How to stream H264 with gstreamer?
body: <p>I need to stream my screen in fullHD, to my android phone with gstreamer, using H264. I'm using <a href="https://github.com/sdroege/gst-launch-remote" rel="nofollow noreferrer">gst launch remote</a> on Android and <code>gst-launch</code> on linux.</p>
  
  <p>I'm starting with gstreamer, I managed to do basic stream following <a href="http://www.einarsundgren.se/gstreamer-basic-real-time-streaming-tutorial/" rel="nofollow noreferrer">this tutorial</a>, but anything a bit different from the examples crashes on various ways.</p>
  
  <p>My basic pipeline is:</p>
  
  <pre><code>ximagesrc use-damage=false xname=/usr/lib/torcs/torcs-bin ! videoconvert ! x264enc tune=zerolatency ! rtph264pay ! udpsink host=192.168.0.100 port=5000
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>udpsrc port=5000 caps=$CAPS ! rtph264depay ! avdec_h264 ! autovideosink
  </code></pre>
  
  <p>I tied to copy the caps from the first pipeline (all or multiple combinations of isolated parameters) to <code>$CAPS</code> but didn't work.</p>
  
  <p>With </p>
  
  <pre><code>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"
  </code></pre>
  
  <p>the pipeline isn't constructed, the only error is:</p>
  
  <pre><code>WARNING: erroneous pipeline: could not link udpsrc0 to rtph264depay0
  </code></pre>
  
  <p>Or with caps </p>
  
  <pre><code>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
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data flow error.
  </code></pre>
  
  <p>Error message witout caps:</p>
  
  <pre><code>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 ...
  </code></pre>