What does 'Past duration X.XXX too large' mean?

One of the maintainers for the DVDStyler project on SourceForge said this about it:

FFMpeg versions after Jan 15 2015 often display this warning. It has been added to warn about possible rate control distortion, otherwise it does not cause any harm.


This warning message appears when trying to encode a high frame rate source to a low frame rate output, which means frames need to be dropped.


I had this error because I wanted to convert a series of images to a video:

ffmpeg -i %05d.png -r 24 -c:v libx264 -crf 5 out.mkv

The problem seems to be, that if no frame rate is give for the input, then a frame rate of 25 fps is assumed:

Input #0, image2, from 'frames/%04d.bmp':
  Duration: 00:00:15.96, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: bmp, bgra, 920x650, 25 fps, 25 tbr, 25 tbn, 25 tbc

This also can be seen on the total number of frames encoded. I had 400 images, but the above command only encoded 384:

frame=  384 fps= 68 q=-1.0 Lsize=   10931kB time=00:00:15.91 bitrate=5626.1kbits/s dup=0 drop=15    
video:10928kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.033807%

The error messages disappears by setting the input frame rate instead if the output frame rate. The output frame rate will then be automatically chosen to be that of the input. Additionally in newer ffmpeg versions you have to watch out, because when using PNG images with the -i option or rather the image2 or v4l2 input format, you have to use -framerate instead of -r, see the documentation for the -r option.

ffmpeg -framerate 24 -i %05d.png -c:v libx264 -crf 5 out.mkv

It is also possible to specify the frame rate of both input and output separately:

ffmpeg -framerate 25 -i %05d.png -r 10 -c:v libx264 -crf 5 out.mkv

In this case only 161/400 frames will be encoded. The other frames interim will be dropped. Also the error message disappears, I guess in order to not slow down ffmpeg by spamming to stdout, see:

  • https://trac.ffmpeg.org/ticket/4700
  • https://trac.ffmpeg.org/ticket/4401

Looking at the source code it seems to be that the difference between the presentation time (pts) in the input stream differs from the one in the output stream by more than a fixed limit set to 0.6 .

Snippets from the source:

    delta0 = sync_ipts - ost->sync_opts;
    delta  = delta0 + duration;

...

        if (delta0 < 0 &&
        delta > 0 &&
        format_video_sync != VSYNC_PASSTHROUGH &&
        format_video_sync != VSYNC_DROP) {
        double cor = FFMIN(-delta0, duration);
        if (delta0 < -0.6) {
            av_log(NULL, AV_LOG_WARNING, "Past duration %f too large\n", -delta0);
        } else
            av_log(NULL, AV_LOG_DEBUG, "Cliping frame in rate conversion by %f\n", -delta0);
        sync_ipts += cor;
        duration -= cor;
        delta0 += cor;
    }

This is only a quick glance, so please feel free to dig deeper.

Tags:

Ffmpeg