title: How to save a RTSP video stream to MP4 file via gstreamer?
body: <p>I need to get a video stream from my camera via RTSP and save it to a file. All of this needs to be done via gstreamer.</p>
  
  <p>After some google searching, I tried the following:</p>
  
  <pre><code>gst-launch-1.0 rtspsrc location=rtsp://192.168.1.184/live2.sdp ! queue ! rtph264depay ! avdec_h264 ! mp4mux ! filesink location=result3.mp4
  </code></pre>
  
  <p>but it gives the error:
  "Erroneous pipeline: could not link avdec_h264-0 to mp4mux0"</p>
  
  <pre><code>gst-launch-1.0 rtspsrc location=rtsp://192.168.1.184/live2.sdp ! queue ! rtph264depay ! h264parse ! mp4mux ! filesink location=result3.mp4
  </code></pre>
  
  <p>It starts doing work, but the result file is not playable via VLC.</p>
  
  <p>What is the right command to do?
  And if you choose between h264parse and avdec_h264, could you please explain why?</p>