title: rtsp stream capturing
body: <p>I'm looking for some universal way to dump rtsp stream. I want to figure out, that some rtsp stream is working well and server is sending some watchable video.</p>
  
  <p><strong>openRTSP</strong></p>
  
  <p>At first, google recommends me <a href="http://www.live555.com/openRTSP/">openRTSP</a> tool. </p>
  
  <pre><code> openRTSP -4 ${stream_link} &gt; ${output_file}
  </code></pre>
  
  <p>But output video file dumped by that tool is not really correct. Video decoder (ffdec) returns many errors like "Failed to decode video packet" and "[h264] no frame!", which don't suit me. </p>
  
  <p><strong>ffmpeg</strong></p>
  
  <p>Then I've tried to dump rtsp stream with ffmpeg tool. </p>
  
  <pre><code>ffmpeg -loglevel debug -i "${stream_link}" -s 640x480 -vcodec copy -acodec copy -y ${output_file}
  </code></pre>
  
  <p>But streaming process was interrupted often by error:</p>
  
  <pre><code>Application provided invalid, non monotonically increasing dts to muxer in stream 0: 730672 &gt;= 730672
  av_interleaved_write_frame(): Invalid argument
  </code></pre>
  
  <p>I'm trying to use <code>--fflags igndts</code> but ffmpeg doesn't ignore these errors. It doesn't make any sense, because that error actually means that audio and video streams are sending asynchronously. The worst thing is that dumped file, resulted by that interrupted dump, is not correct too. Ffdec return some error:</p>
  
  <pre><code>ERROR [mov,mp4,m4a,3gp,3g2,mj2] moov atom not found
  ERROR [ffdec] av_open_input_file: Operation not permitted
  </code></pre>
  
  <p>After a nice cup of googling I've found, that it's really old <a href="http://ffmpeg.org/trac/ffmpeg/ticket/222">ffmpeg's muxer bug</a>. </p>
  
  <p><strong>mplayer</strong></p>
  
  <p>Than I've tried to use mplayer with LIVE_555 lib.</p>
  
  <pre><code>mplayer -noframedrop -dumpfile ${output_file} -dumpstream ${stream_link}
  </code></pre>
  
  <p>But I've got some errors too.</p>
  
  <pre><code>Stream not seekable!
  Core dumped ;)
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>I think I'm doing something wrong. It's sounds really ridiculous, that there is no way to save rtsp stream in correct and playable video-file.</p>
  
  <p>Maybe there are some another tools which can help with that task? Actually, I will be grateful for any advice for all kind of libs and languages. But that process should be automatic and have cli.</p>
  
  <p><strong>Refinements</strong></p>
  
  <p>Something about 50% experiments I've done on the localhost with vlc-streamer that emulates rtsp-broadcaster. Here is a <a href="http://www.youtube.com/watch?v=VsahDWNByVQ">manual</a> which I try to follow.</p>
  
  <p>I have really fresh and latest ffmpeg with x264 support, that I've installed by <a href="http://ubuntuforums.org/showthread.php?t=786095">that</a> useful thread.</p>