How to Fix ‘Past Duration Too Large’ Error in FFmpeg?
FFmpeg is a free to use and open source program that is used for handling Video, Audio, and other multimedia streams. The program has been designed to handle command line based handling of processing of video and audio files. However, quite recently, a lot of reports have been coming in of a “Past Duration Too Large” Error while encoding or downscaling a video.
What Causes the “Past Duration Too Large” Error in FFmpeg?
After receiving numerous reports from multiple users, we decided to investigate the issue and devised a set of solutions to completely rectify it. Also, we looked into the reasons due to which this error is triggered and listed them as follows:
- Input Framerate Missing: In most cases, the issue is caused due to the input framerate not being entered for the images. This results in the program assuming that the input framerate is 25 fps which can cause problems if that is not the case.
- Sync Settings not Implemented: With most users, implementing certain sync settings fixed the issue. Sometimes, the frames might not get synced properly due to which certain frames might be dropped and this error might be triggered.
Now that you have a basic understanding of the nature of the issue, we will move on towards the solutions. Make sure to implement these in the specific order in which they are presented to avoid conflict.
Solution 1: Adding Input Frames
If the input framerate of the video hasn’t been added it might result in some frames getting dropped and the error is triggered. Therefore, in this step, we will be adding the input frames for that:
- Observe the convocation that you used to convert the video, it might be on similar to the following
ffmpeg -i %05d.png -r 24 -c:v libx264 -crf 5 out.mkv
- Now simply add the framerate to the convocation used as follows
ffmpeg -framerate 24 -i %05d.png -c:v libx264 -crf 5 out.mkv
- Check to see if the issue persists.
Solution 2: Using Sync Flags
Adding the Sync flags can help sync the output and the input video according to the video’s initial framerates. Therefore, If the sync commands haven’t been added, it is possible that the frames aren’t being synced properly. In this step, we will be adding the sync commands
- At this stage, you must probably be using the following convocation
ffmpeg -framerate 24 -i %05d.png -c:v libx264 -crf 5 out.mkv
- However, instead of this, use the following convocation
ffmpeg -framerate 24 -i %05d.png -c:v libx264 -crf 5 out.mkv -async 1 -vsync 1
- Note that we have just added the “-async 1 -vsync1” to the convocation and this needs to be added at the end of the convocation that you are using.
Note: Your initial convocation might differ from the one used as an example. The changes added to the convocation, however, should not differ.