Opened 5 years ago

Closed 5 years ago

#1788 closed defect (duplicate)

setting the output frame rate of image outputs

Reported by: burek Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes


I'm not sure if this is a bug or not, since I was suggested that ffmpeg is not designed to be used in such way, but I can surely ask anyway :)

Summary of the bug:
Trying to extract 1 frame each 5 seconds of the video input to an image output, by setting the output frame rate to 1/5 produces the expected result but with the first 3 output frames failed (not correctly timed).

How to reproduce:

ffmpeg -f lavfi -i testsrc -t 60 -f image2 -r 1/5 img%02d.bmp
ffmpeg -f lavfi -i testsrc -t 60 -f image2 -r 1/5 img%02d.jpg
ffmpeg -f lavfi -i testsrc -t 60 -f image2 -r 1/5 img%02d.png

All of the commands above will produce first 3 output image frames wrong, but all the other frames will be correctly created, meaning that img01.*, img02.* and img03.* will be wrong and img04.*, img05.*, ... will be correct. The time difference between frames is correct only the starting time point is wrong, I guess due to those first 3 frames not being created properly.

Change History (2)

comment:1 Changed 5 years ago by Cigaes

  • Analyzed by developer set
  • Component changed from undetermined to FFmpeg
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from unspecified to git-master

This is related to the rounding heuristics for the video sync implementation in ffmpeg.c:

        // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
        if (delta < -1.1)
            nb_frames = 0;

In this code, delta is the difference between the current time on the stream and the time of the incoming frame. If no frame rate adjustment is necessary, it is always 1. Theoretically, the frame should be dropped as soon as it is less than 1, but as you can see, the current code gives it a little head start.

Replacing -1.1 by 1 fixes your problem but breaks a lot of FATE tests. I do not know that part of the code enough to determine whether changing it would be correct.

In the meantime, you can use the fps filter: -vf fps=fps=1/5 (or possibly -vf fps=fps=1/5:round=down with a patch I just sent).

comment:2 Changed 5 years ago by cehoyos

  • Resolution set to duplicate
  • Status changed from open to closed

Duplicate of ticket #1578.

Note: See TracTickets for help on using tickets.