Body: <p>I am using java to create image files that I am converting to video using FFMPEG. I am creating the midi and audio simultaneously on reaper then using the duration of the notes on the midi file to create the number of frames I need. These are the durations of the different notes I have:</p>
  
  <pre><code>306.1224966434529
  612.2449932869058
  1224.4899865738262
  1836.734979860732
  </code></pre>
  
  <p>In order to get the frames I need I am using the formula (fps * duration) / 1000 then rounding down which results in:</p>
  
  <pre><code>306.1224966434529 -&gt; 18 frames
  612.2449932869058 -&gt; 36 frames
  1224.4899865738262 -&gt; 72 frames
  1836.734979860732 -&gt; 110 frames
  </code></pre>
  
  <p>When I combine the audio it gradually goes out of sync. I played around and realised that the 72 frames require 74 frames and the 110 frame notes require 112 frames.</p>
  
  <p>I am not sure how to account for this. I need to be able to calculate the number of frames required ahead of time rather than creating them in real time.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-14T21:52:46.743Z
Comments.Text: Are you using a [drop frame](https://en.wikipedia.org/wiki/SMPTE_timecode?wprov=sfla1) or non-drop frame rate? Please share your full ffmpeg command.
Comments.UserDisplayName: Michael Liebman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-15T19:42:00.953Z
Comments.Text: Thanks for responding. I am not explicitly using either so whatever the default is. I managed to get it working by increasing the frame rate. 180fps + gets a good degree of accuracy so I think the precision wasn't close enough after rounding.
Comments.UserDisplayName: Ryan McCauley
Tags: <video><ffmpeg><audio><framerate>
Title: Trying to understand the delay converting a sequence of images to video
UserDisplayName: Ryan McCauley
ThreadText: # Trying to understand the delay converting a sequence of images to video
  
  (Asked by: username_0 on 2017-09-14)
  
  I am using java to create image files that I am converting to video using FFMPEG. I am creating the midi and audio simultaneously on reaper then using the duration of the notes on the midi file to create the number of frames I need. These are the durations of the different notes I have:
  
  ```
  306.1224966434529
  612.2449932869058
  1224.4899865738262
  1836.734979860732
  
  ```
  
  In order to get the frames I need I am using the formula (fps \* duration) / 1000 then rounding down which results in:
  
  ```
  306.1224966434529 -> 18 frames
  612.2449932869058 -> 36 frames
  1224.4899865738262 -> 72 frames
  1836.734979860732 -> 110 frames
  
  ```
  
  When I combine the audio it gradually goes out of sync. I played around and realised that the 72 frames require 74 frames and the 110 frame notes require 112 frames.
  
  I am not sure how to account for this. I need to be able to calculate the number of frames required ahead of time rather than creating them in real time.
  
  **Tags:** video, ffmpeg, audio, framerate
  
  > **Comments:**
  > **username_1**: Are you using a [drop frame](https://en.wikipedia.org/wiki/SMPTE_timecode?wprov=sfla1) or non-drop frame rate? Please share your full ffmpeg command.  
  > **username_0**: Thanks for responding. I am not explicitly using either so whatever the default is. I managed to get it working by increasing the frame rate. 180fps + gets a good degree of accuracy so I think the precision wasn't close enough after rounding.  
  
  ---
  
  ## 0 answers
  
  