title: ffmpeg - live video from rtsp with mp4 fragmented
body: <p>I have the following setup:</p>
  <ul>
  <li>Raspberry 4B (4GB RAM)</li>
  <li>Raspbian 10 (buster)</li>
  <li>ffmpeg 4.1.6</li>
  </ul>
  <p>What I want to try:</p>
  <p>I want to make a one-to-one video stream from a RTSP stream to my browser, without saving files (like .ts or .m3u), but just push the raw mp4 stream over the network in a HTML5 video tag.</p>
  <p>I had already some successes, but it was never a smooth or good video stream, but always stopped and continued.</p>
  <p>I used PHP <code>passthru()</code> function to call ffmpeg and i piped the video stream on the end</p>
  <p>Here are some attempts:</p>
  <pre class="lang-php prettyprint-override"><code>header(&quot;Cache-Control: no-store, no-cache, must-revalidate, max-age=0&quot;);
  header(&quot;Cache-Control: post-check=0, pre-check=0&quot;, false);
  header(&quot;Pragma: no-cache&quot;);
  header(&quot;Accept-Ranges: bytes&quot;);
  header(&quot;Connection: keep-alive&quot;);
  
  passthru(&quot;ffmpeg -rtsp_transport tcp -i \&quot;rtsp://192.168.0.1:554/livestream/12\&quot; -c:v copy -b:v 2M -movflags frag_keyframe+empty_moov -f mp4 pipe:&quot;);
  
  passthru(&quot;ffmpeg -rtsp_transport tcp -i \&quot;rtsp://192.168.0.1:554/livestream/12\&quot; -b 1024k -minrate 1024k -bufsize 2048k -r 20 -movflags frag_keyframe+empty_moov -f mp4 pipe:&quot;);
  
  passthru(&quot;ffmpeg -rtsp_transport tcp -i rtsp://192.168.0.1:554/livestream/12 -r 10 -t 60 -movflags frag_keyframe -f mp4 pipe:&quot;);
  </code></pre>