cv2.VIDEOWRITER记录的文件的速度不正确
使用以下代码:
import cv2
import numpy as np
from win32api import GetSystemMetrics # screen size
import elapsed
import datetime
screen_width = GetSystemMetrics (0)
screen_height = GetSystemMetrics (1)
resolution = (screen_width, screen_height)
codec = cv2.VideoWriter_fourcc(*'x264')
filename = ".\\screen_video.mp4"
fps = 30.0
out = cv2.VideoWriter(filename, codec, fps, resolution)
record_timer = datetime.datetime.now()
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
if elapsed.get (record_timer ).seconds >= 30: break
out.release()
我正在录制屏幕的30秒视频。
问题是:记录的视频速度不正确。太快了。确切地说,结果是6秒钟的视频,而不是30秒的正常视频。 它不是滞后的,我的意思是正确记录了所有内容,只是以“快进”方式。
我检查了这些解决方案,但没有解决我的问题: cvideWriter的输出不正确。它更快
您能帮我,请问这里有什么问题?非常感谢提前的任何具体帮助!
Using the following code:
import cv2
import numpy as np
from win32api import GetSystemMetrics # screen size
import elapsed
import datetime
screen_width = GetSystemMetrics (0)
screen_height = GetSystemMetrics (1)
resolution = (screen_width, screen_height)
codec = cv2.VideoWriter_fourcc(*'x264')
filename = ".\\screen_video.mp4"
fps = 30.0
out = cv2.VideoWriter(filename, codec, fps, resolution)
record_timer = datetime.datetime.now()
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
if elapsed.get (record_timer ).seconds >= 30: break
out.release()
I am recording a 30 sec video of my screen.
Problem is: the recorded video speed is incorrect. It is just too fast. To be precise, instead of a 30 sec normal video, the result is a 6 seconds video. It is not lagging, I mean all content recorded correctly, just in a "fast forward" way.
I check these solutions, but did not solved my problem:
The output of cv2.VideoWriter is incorrect. It's faster
Can you help me please what can be the problem here? Many thanks in advance for any concrete help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论