如何设置 fps 以从视频中提取帧?
我有一个大约 30
fps 的视频。我想使用 cap.set(cv2.CAP_PROP_FPS, int(fps_num))
手动将 fps 速率设置为 70
。但它总是给出 False
作为输出。我该如何解决这个问题?
import cv2
fps_num = 70
file = "./test.mp4"
cap = cv2.VideoCapture(file)
cap.set(cv2.CAP_PROP_FPS, int(fps_num))
输出:错误
I have a video around 30
fps. I want set fps rate to 70
manually with cap.set(cv2.CAP_PROP_FPS, int(fps_num))
. But it always gives False
as an output. How can I fix this issue?
import cv2
fps_num = 70
file = "./test.mp4"
cap = cv2.VideoCapture(file)
cap.set(cv2.CAP_PROP_FPS, int(fps_num))
output: False
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在从流中读取内容。您可以获取原始视频的 FPS 速率。如果你想设置FPS速率,那就意味着你想写一个输出流。请参阅
cv::VideoWriter
。You are reading from the stream. You can get the FPS rate of the original video. If you want to set the FPS rate, that means you want to write an output stream. See
cv::VideoWriter
.