Answers.Body: <p>I found a Japanese article while searching the internet and thought it might be what you were looking for, so I am posting it. Please translate it in any way you like.<br />
  &quot;<a href="https://qiita.com/mitayuki6/items/73943628b625e0b2ab30" rel="nofollow noreferrer">Save images generated in real time with OpenCV as a variable frame rate video</a>&quot;, (<a href="https://qiita-com.translate.goog/mitayuki6/items/73943628b625e0b2ab30?_x_tr_sl=auto&amp;_x_tr_tl=en&amp;_x_tr_hl=en-US&amp;_x_tr_pto=wapp" rel="nofollow noreferrer">Google Translate</a>).</p>
  <p>I consider this to be a way to accept images with variable frame rates in situations like yours. I'm not confident in coding, but after trying various things, I was able to get a fixed rate image as shown below.</p>
  <p>(However, I was not able to get a video, and I was having trouble with the broken pipe error 32 due to the termuxX11 environment.)</p>
  <pre><code>fpsns = 0.00333  # nearly 30fps interval
  endns = 0.0                                                                
  
  if interval &gt; fpsns:
      interval = ((time.time_ns()/1000000000) - endns)
  
      # capture or something here
  
      endns = time.time_ns() / 1000000000000
  else:
      logging.debug(f'not capture timming {str(interval)[:6]}')
      continue
  </code></pre>
  <p><em>I made a small correction because I was wrong code part.</em></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-18T14:15:42.383Z
Answers.LastActivityDate: 2024-11-08T12:31:04.737Z
Answers.LastEditDate: 2024-11-08T12:31:04.737Z
Answers.UserDisplayName: Suletta-Majo
Body: <p>I'm encoding a video by piping images into <code>ffmpeg</code> using the <code>-i pipe:</code> input.
  However the images arrive sporadically, but are encoded as if they are sequential frames.</p>
  <p>I have tried using <code>-use_wallclock_as_timestamps 1</code> in the input block, but it has no effect.</p>
  <p>This is the command I'm using:</p>
  <p><code>ffmpeg -use_wallclock_as_timestamps 1 -i pipe: -vf fps=50 -c:v libx264 -map 0 -f segment -segment_list playlist.m3u8 -segment_list_flags +live -segment_time 10 -segment_wrap 5 seg%03d.mkv</code></p>
  <p>Input block parameters I've tried to no avail:</p>
  <ul>
  <li><code>-re</code></li>
  <li><code>-framerate 1</code></li>
  <li><code>-framerate 1/1000</code></li>
  <li><code>-framerate 50</code></li>
  </ul>
  <p>So to reiterate the problem: A video is being produced, but each piped image is set as an individual frame, despite having arrived and encoded at an entirely different time than its predecessor.</p>
  
Tags: <ffmpeg>
Title: Encode piped images as they arrive with real time timestamps
UserDisplayName: Aviad P.
ThreadText: # Encode piped images as they arrive with real time timestamps
  
  (Asked by: username_0 on 2024-08-02)
  
  I'm encoding a video by piping images into `ffmpeg` using the `-i pipe:` input.
  However the images arrive sporadically, but are encoded as if they are sequential frames.
  
  I have tried using `-use_wallclock_as_timestamps 1` in the input block, but it has no effect.
  
  This is the command I'm using:
  
  `ffmpeg -use_wallclock_as_timestamps 1 -i pipe: -vf fps=50 -c:v libx264 -map 0 -f segment -segment_list playlist.m3u8 -segment_list_flags +live -segment_time 10 -segment_wrap 5 seg%03d.mkv`
  
  Input block parameters I've tried to no avail:
  
  * `-re`
  * `-framerate 1`
  * `-framerate 1/1000`
  * `-framerate 50`
  
  So to reiterate the problem: A video is being produced, but each piped image is set as an individual frame, despite having arrived and encoded at an entirely different time than its predecessor.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-10-18. Score: 0
  
  I found a Japanese article while searching the internet and thought it might be what you were looking for, so I am posting it. Please translate it in any way you like.  
  "[Save images generated in real time with OpenCV as a variable frame rate video](https://qiita.com/mitayuki6/items/73943628b625e0b2ab30)", ([Google Translate](https://qiita-com.translate.goog/mitayuki6/items/73943628b625e0b2ab30?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp)).
  
  I consider this to be a way to accept images with variable frame rates in situations like yours. I'm not confident in coding, but after trying various things, I was able to get a fixed rate image as shown below.
  
  (However, I was not able to get a video, and I was having trouble with the broken pipe error 32 due to the termuxX11 environment.)
  
  ```
  fpsns = 0.00333  # nearly 30fps interval
  endns = 0.0                                                                
  
  if interval > fpsns:
      interval = ((time.time_ns()/1000000000) - endns)
  
      # capture or something here
  
      endns = time.time_ns() / 1000000000000
  else:
      logging.debug(f'not capture timming {str(interval)[:6]}')
      continue
  
  ```
  
  *I made a small correction because I was wrong code part.*
  
  
  ---
  
  