title: Streaming audio and video in sync for mp4 container using Gstreamer framework
body: <p>I am new to gstreamer and I want to stream a mp4 video which is having audio and video both from my Host(Ubuntu PC) to target board. I have successfully streamed only video. But streaming both(audio and video) is not happening.</p>
  
  <p>Pipeline to stream only video is as below</p>
  
  <p>Sender:</p>
  
  <blockquote>
    <p><strong>gst-launch-1.0 -v filesrc location = video.mp4 ! decodebin ! x264enc ! rtph264pay ! udpsink host=192.168.2.136 port=5000</strong></p>
  </blockquote>
  
  <p>receiver:</p>
  
  <blockquote>
    <p><strong>gst-launch-1.0 -v udpsrc port=5000 caps="application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, payload=96, ssrc=3394826012, timestamp-offset=2215812541, seqnum-offset=46353" ! rtph264depay ! avdec_h264 ! videoconvert ! ximagesink sync=false</strong></p>
  </blockquote>
  
  <p>Hence, can see video on target.</p>
  
  <p>Did streaming of only audio from mp4 file.</p>
  
  <p>Pipeline to stream only video is as below</p>
  
  <p>Sender:</p>
  
  <blockquote>
    <blockquote>
      <p><strong>gst-launch-1.0 -v  filesrc location=video.mp4 ! qtdemux name=demuxer demuxer. ! queue ! rtpmp4apay pt=97 ! udpsink host=192.168.2.69 port=5000</strong></p>
    </blockquote>
  </blockquote>
  
  <p>Receiver:</p>
  
  <blockquote>
    <blockquote>
      <p><strong>gst-launch-1.0 -v udpsrc port=5000 caps="application/x-rtp, media=audio, clock-rate=44100, encoding-name=MP4A-LATM, cpresent=0, config=40002420, payload=97, ssrc=3386264266, timestamp-offset=2822202855, seqnum-offset=17719" ! rtpmp4adepay ! decodebin ! alsasink &amp;</strong></p>
    </blockquote>
  </blockquote>
  
  <p>This too runs successfully.</p>
  
  <p>But when I tried below pipeline to stream both audio/video in sync:</p>
  
  <p>Sender:</p>
  
  <blockquote>
    <blockquote>
      <p><strong>gst-launch-1.0 -v  filesrc location=sample.mp4 ! qtdemux name=demux demux. ! queue ! rtph264pay pt=96 ! udpsink host=192.168.3.101 port=5000 demux. ! queue ! rtpmp4apay pt=97 ! udpsink host=192.168.3.101 port=5001</strong></p>
    </blockquote>
  </blockquote>
  
  <p>Receiver:</p>
  
  <blockquote>
    <blockquote>
      <p><strong>gst-launch-1.0 -v udpsrc port=5000 caps="application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, payload=96, ssrc=2226494377, timestamp-offset=3242004369, seqnum-offset=17021" ! rtph264depay ! decodebin ! ximagesink  udpsrc port=5001 caps="application/x-rtp, media=audio, clock-rate=44100, encoding-name=MP4A-LATM, cpresent=0, config=40002420, payload=97, ssrc=1499706502, timestamp-offset=190741668, seqnum-offset=24774" ! rtpmp4adepay ! decodebin ! alsasink</strong></p>
    </blockquote>
  </blockquote>
  
  <p>But: get an output as below:</p>
  
  <blockquote>
    <blockquote>
      <p><strong>ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin1/GstFaad:faad0: Could not decode stream.</strong></p>
    </blockquote>
  </blockquote>
  
  <p>fails.
  Please can someone suggest me a pipeline which can stream audio/video both on target device in sync.</p>
  
  <p>Thanks in advance.</p>