title: Save H264 encoded stream without re-encoding
body: <p>I have a gstreamer pipeline that streams using :</p>
  
  <pre><code>v4l2src ! x264enc ! rtph264pay pt=96 ! udpsink host=ip port=8554
  </code></pre>
  
  <p>And this pipeline that receives this stream :</p>
  
  <pre><code>                                                                /   queue !     avdec_h264 ! appsink
  udpsrc ! capsfilter ! rtpjitterbuffer ! rtph264depay ! tee ! 
                                                                  \   queue ! h264parse ! mp4mux ! filesink
  </code></pre>
  
  <p>Simplified receiver pipeline without the tee is :</p>
  
  <pre><code>gst-launch-1.0 udpsrc port=8080 caps="lots-of-caps" ! rtpjitterbuffer ! rtph264depay ! h264parse ! mp4mux ! filesink location=/home/rish/Desktop/recorded.264 -e 
  </code></pre>
  
  <p>Question : 
  Is there a way to save the H264 encoded stream received from udpsrc without having to re-encode it? How do I correctly close the filesink?</p>
  
  <p>What I've tried so far : The discussion from <a href="https://lists.freedesktop.org/archives/gstreamer-devel/2012-May/035999.html" rel="nofollow noreferrer">this</a> thread suggests the pipeline I've tried above but file is still corrupt. (not correctly closed).</p>
  
  <p><a href="https://stackoverflow.com/questions/25840509/how-to-save-a-rtsp-video-stream-to-mp4-file-via-gstreamer">This</a> question asks a similar question. However I do not want to decode and re-encode. Another answer in the thread suggests using matroskamux element instead of mp4mux. This works, but I'd rather prefer using mp4mux (no particular reason, but I'd like to know why matroskamux works and mp4mux doesn't).</p>