Answers.Body: <p>I've solved my issue by switching webservers. Previously, I was using Python's builtin http.server, which was taking over 2 seconds to serve a single 2-second segment. (Naturally, this caused clientside stuttering and forced it to increase its buffer.)</p>
  <p>Now, using Apache (though any other production webserver would probably be just as good) I'm enjoying stutter-free streaming at acceptable latency levels.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-10T20:24:10.390Z
Answers.LastActivityDate: 2022-12-10T20:24:10.390Z
Answers.UserDisplayName: archfan7411
Body: <p>I am presently using ffmpeg to pull a stream from a camera using RTSP, and then output it as an HLS stream. I also have a webpage with a video.js player, using the example code found on <a href="https://videojs.com/getting-started/" rel="nofollow noreferrer">this page</a>.</p>
  <p>My full ffmpeg command is as follows:</p>
  <pre><code>ffmpeg -rtsp_transport tcp -fflags nobuffer -i rtsp://my_rtsp_url_here -c copy -f hls -hls_base_url http://my_base_url_here/ -hls_time 2 -hls_list_size 8 -hls_flags delete_segments stream.m3u8
  </code></pre>
  <p>(As you can see, I've already done some things in an attempt to reduce latency, such as setting -fflags nobuffer.)</p>
  <p>Currently, latency seems to be sitting at at least 12 seconds, though I don't have an exact measure. I would be interested in any suggestions for reducing latency, even if that means switching protocols. The only requirement is that I'd like to be able to serve this stream on a webpage.</p>
  <p>I suspect that reducing video.js' buffer might help, but I don't know how to go about doing that.</p>
  
Tags: <ffmpeg><hls><latency>
Title: Reducing latency with ffmpeg RTSP->HLS->video.js
UserDisplayName: archfan7411
ThreadText: # Reducing latency with ffmpeg RTSP->HLS->video.js
  
  (Asked by: username_0 on 2022-11-30)
  
  I am presently using ffmpeg to pull a stream from a camera using RTSP, and then output it as an HLS stream. I also have a webpage with a video.js player, using the example code found on [this page](https://videojs.com/getting-started/).
  
  My full ffmpeg command is as follows:
  
  ```
  ffmpeg -rtsp_transport tcp -fflags nobuffer -i rtsp://my_rtsp_url_here -c copy -f hls -hls_base_url http://my_base_url_here/ -hls_time 2 -hls_list_size 8 -hls_flags delete_segments stream.m3u8
  
  ```
  
  (As you can see, I've already done some things in an attempt to reduce latency, such as setting -fflags nobuffer.)
  
  Currently, latency seems to be sitting at at least 12 seconds, though I don't have an exact measure. I would be interested in any suggestions for reducing latency, even if that means switching protocols. The only requirement is that I'd like to be able to serve this stream on a webpage.
  
  I suspect that reducing video.js' buffer might help, but I don't know how to go about doing that.
  
  **Tags:** ffmpeg, hls, latency
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-12-10. Score: 0 | Accepted answer
  
  I've solved my issue by switching webservers. Previously, I was using Python's builtin http.server, which was taking over 2 seconds to serve a single 2-second segment. (Naturally, this caused clientside stuttering and forced it to increase its buffer.)
  
  Now, using Apache (though any other production webserver would probably be just as good) I'm enjoying stutter-free streaming at acceptable latency levels.
  
  
  ---
  
  