Answers.Body: <p>Add <code>-follow 1</code> before the input i.e.</p>
  <pre><code>ffmpeg -y \
      -rw_timeout 30M -follow 1 -i ./appdata/input/Sintel.mkv \
  </code></pre>
  <p>Note that the option belongs to the file protocol. It won't apply to other protocols, and ability to wait for further data depends on whether the other protocol allows it.</p>
  <p>The option <code>-rw_timeout</code> is needed to terminate the file read. If no updates have occurred in that interval, ffmpeg will treat it as EOF. Its value is in microseconds i.e. <code>1M</code> = 1 million microseconds = 1 second.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-29T16:23:01.243Z
Answers.Text: Thank you my friend, you are a true life saviour
Answers.UserDisplayName: Vjerci
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-28T04:43:15.790Z
Answers.LastActivityDate: 2023-12-28T05:24:05.393Z
Answers.LastEditDate: 2023-12-28T05:24:05.393Z
Answers.UserDisplayName: Gyan
Body: <p>I am partially downloading a video file, sequentially.</p>
  <p>What I've managed to achieve is for FFmpeg to encode the file as it is being downloaded if the download is faster than encoding. I cannot guarantee that the download will always be faster than encoding.</p>
  <p>When download becomes slower than encoding I get this error, and ffmpeg exists:</p>
  <pre><code>[matroska,webm @ 0x1248040d0] File ended prematurely
  </code></pre>
  <p>What I am hoping to achieve is for FFmpeg to wait/hang until new bits are added to the input file, and continue with encoding when it has enough of bits for a new segment until file is complete.</p>
  <p>I am using this command to generate hls stream:</p>
  <pre><code>    ffmpeg -y \
          -i ./appdata/input/Sintel.mkv \
          -preset fast \
          -c:a aac \
          -b:a 192k \
          -ac 2 \
          -c:v libx264 \
          -b:v 1024k \
          -profile:v high \
          -level 4.1 \
          -crf 34 \
          -pix_fmt yuv420p \
          -threads 0 \
          -f hls \
          -hls_list_size 0 \
          -hls_time 10 \
          -hls_playlist_type event \
          -hls_flags independent_segments+append_list \
          -master_pl_name &quot;livestream.m3u8&quot; \
          ./appdata/test/livestream-%v.m3u8
  </code></pre>
  <p>Can FFmpeg monitor and process the input as new bits are added to the input file?</p>
  <p>Best solution I got so far was is to use segments and segments list from this answer:
  <a href="https://video.stackexchange.com/questions/32297/resuming-a-partially-completed-encode-with-ffmpeg">Resuming a partially-completed encode with FFmpeg</a></p>
  <p>And couple it with some programming to keep retrying in the loop until the input file is complete, however, that feels like a bad solution that I would love to avoid.</p>
  
Tags: <ffmpeg>
Title: FFMPEG encoding partial file and monitoring input for addition
UserDisplayName: Vjerci
ThreadText: # FFMPEG encoding partial file and monitoring input for addition
  
  (Asked by: username_0 on 2023-12-27)
  
  I am partially downloading a video file, sequentially.
  
  What I've managed to achieve is for FFmpeg to encode the file as it is being downloaded if the download is faster than encoding. I cannot guarantee that the download will always be faster than encoding.
  
  When download becomes slower than encoding I get this error, and ffmpeg exists:
  
  ```
  [matroska,webm @ 0x1248040d0] File ended prematurely
  
  ```
  
  What I am hoping to achieve is for FFmpeg to wait/hang until new bits are added to the input file, and continue with encoding when it has enough of bits for a new segment until file is complete.
  
  I am using this command to generate hls stream:
  
  ```
      ffmpeg -y \
          -i ./appdata/input/Sintel.mkv \
          -preset fast \
          -c:a aac \
          -b:a 192k \
          -ac 2 \
          -c:v libx264 \
          -b:v 1024k \
          -profile:v high \
          -level 4.1 \
          -crf 34 \
          -pix_fmt yuv420p \
          -threads 0 \
          -f hls \
          -hls_list_size 0 \
          -hls_time 10 \
          -hls_playlist_type event \
          -hls_flags independent_segments+append_list \
          -master_pl_name "livestream.m3u8" \
          ./appdata/test/livestream-%v.m3u8
  
  ```
  
  Can FFmpeg monitor and process the input as new bits are added to the input file?
  
  Best solution I got so far was is to use segments and segments list from this answer:
  [Resuming a partially-completed encode with FFmpeg](https://video.stackexchange.com/questions/32297/resuming-a-partially-completed-encode-with-ffmpeg)
  
  And couple it with some programming to keep retrying in the loop until the input file is complete, however, that feels like a bad solution that I would love to avoid.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-12-28. Score: 2 | Accepted answer
  
  Add `-follow 1` before the input i.e.
  
  ```
  ffmpeg -y \
      -rw_timeout 30M -follow 1 -i ./appdata/input/Sintel.mkv \
  
  ```
  
  Note that the option belongs to the file protocol. It won't apply to other protocols, and ability to wait for further data depends on whether the other protocol allows it.
  
  The option `-rw_timeout` is needed to terminate the file read. If no updates have occurred in that interval, ffmpeg will treat it as EOF. Its value is in microseconds i.e. `1M` = 1 million microseconds = 1 second.
  
  > **Comments:**
  > **username_0**: Thank you my friend, you are a true life saviour  
  
  ---
  
  