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:


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.

  • Are you using a drop frame or non-drop frame rate? Please share your full ffmpeg command. – Michael Liebman Sep 14 '17 at 21:52
  • 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. – Ryan McCauley Sep 15 '17 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.