简体   繁体   中英

ffmpeg: same video, same framerate, different number of output frames. Why?

I need to extract the frames from a video at 30fps twice: (i) 720p png frames, and (ii) 270p tiff frames.

I achieve this using the following commands respectively:

ffmpeg -r 30 -i myvideo.mp4 -s 1280x720 frames/myvideo_%06d.png

ffmpeg -y -i myvideo.mp4 -an -r 30 -pix_fmt rgb24 -vcodec tiff -s 480x270 frames/myvideo_%06d.tif

However, this results in the first command outputting 35,776 frames and the second command outputting 35,812 frames, despite the video being identical and the framerate requested being 30fps.

What is causing this? How can I ensure that ffmpeg outputs the same number of (synchronised) frames?

Specifying -r before the -i command specifies the input video rate. Specifying -r after the -i command specifies the output video rate.

Specifying -r before the input tells/forces ffmpeg to chose the specified frame rate. If you specify -r after the input sequence, ffmpeg has to guess the input frame rate which can cause loss of frames, which is seen in your second case.

The same applies for the input resolution as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM