简体   繁体   English

ffmpeg:相同的视频,相同的帧速率,不同数量的输出帧。 为什么?

[英]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. 我需要两次以30fps的速度从视频中提取帧:(i)720p png帧和(ii)270p tiff帧。

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. 但是,尽管视频相同且请求的帧速率为30fps,这导致第一命令输出35,776帧,第二命令输出35,812帧。

What is causing this? 是什么原因造成的? How can I ensure that ffmpeg outputs the same number of (synchronised) frames? 如何确保ffmpeg输出相同数量的(同步)帧?

Specifying -r before the -i command specifies the input video rate. 在-i命令之前指定-r指定输入视频速率。 Specifying -r after the -i command specifies the output video rate. 在-i命令之后指定-r可以指定输出视频速率。

Specifying -r before the input tells/forces ffmpeg to chose the specified frame rate. 在输入告诉/强制ffmpeg选择指定的帧速率之前指定-r。 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. 如果在输入序列之后指定-r,则ffmpeg必须猜测可能导致帧丢失的输入帧速率,这在第二种情况下可见。

The same applies for the input resolution as well. 输入分辨率也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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