Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 录制OpenCV视频的最佳fps是什么?_Python_Python 3.x_Opencv - Fatal编程技术网

Python 录制OpenCV视频的最佳fps是什么?

Python 录制OpenCV视频的最佳fps是什么?,python,python-3.x,opencv,Python,Python 3.x,Opencv,我正在修补OpenCV,我在想我应该录制什么样的fps时遇到了一些问题。当我以15fps的速度录制时,录制的片段比“真实生活”要快得多。我想知道是否有一个“最佳”的fps,我可以录制,这样录制的时间将与拍摄视频所需的时间一样长 以下是我正在运行的程序(尽管我认为这与问题无关): 比如说你的摄像机以每秒25帧的速度记录。如果您的相机以25 FPS的速度录制视频,而您的相机以15 FPS的速度拍摄视频,则视频速度将比现实生活快约1.6倍 您可以使用get(CAP\u PROP\u FPS)或get(

我正在修补OpenCV,我在想我应该录制什么样的fps时遇到了一些问题。当我以
15fps
的速度录制时,录制的片段比“真实生活”要快得多。我想知道是否有一个“最佳”的fps,我可以录制,这样录制的时间将与拍摄视频所需的时间一样长

以下是我正在运行的程序(尽管我认为这与问题无关):


比如说你的摄像机以每秒25帧的速度记录。如果您的相机以25 FPS的速度录制视频,而您的相机以15 FPS的速度拍摄视频,则视频速度将比现实生活快约1.6倍

您可以使用
get(CAP\u PROP\u FPS)
get(CV\u CAP\u PROP\u FPS)
查找帧速率,但除非源文件是视频文件,否则帧速率无效

对于摄像头或网络摄像头,您必须以编程方式计算(估计)FPS:

num_frames = 240; # Number of frames to capture

print "Capturing {0} frames".format(num_frames)

start = time.time()# Start time

# Grab a few frames
for i in xrange(0, num_frames) :
    ret, frame = video.read()

end = time.time() # End time

seconds = end - start # Time elapsed
print "Time taken : {0} seconds".format(seconds)

# Calculate frames per second
fps  = num_frames / seconds;
print "Estimated frames per second : {0}".format(fps);
所以这个程序通过记录前240帧作为样本来估计视频源的帧速率,然后计算增量时间。最后,简单除法的结果给出FPS

num_frames = 240; # Number of frames to capture

print "Capturing {0} frames".format(num_frames)

start = time.time()# Start time

# Grab a few frames
for i in xrange(0, num_frames) :
    ret, frame = video.read()

end = time.time() # End time

seconds = end - start # Time elapsed
print "Time taken : {0} seconds".format(seconds)

# Calculate frames per second
fps  = num_frames / seconds;
print "Estimated frames per second : {0}".format(fps);