Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
540 views
in Technique[技术] by (71.8m points)

python - OpenCV VideoWriter speed goes up as outside becoming darker

I have a simple opencv program to save a video from my USB camera. Camera has few supported resolutions

1600x1200 <= 5fps
1280x720 <= 11.120fps
800x600 <= 20fps
640x480 <= 30fps

I'm using it this way: (It's just a strip from my code)

cam = cv2.VideoCapture(0)

width = int(cam.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cam.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = cv2.CAP_PROP_FPS

cam.set(3, width)
cam.set(4, height)

fourcc = cv2.VideoWriter_fourcc(*"mp4v")

out = cv2.VideoWriter(file_name, fourcc, fps, (width, height))
while cam.isOpened():
    img = cam.read()[1]
    out.write(main_img)

# etc....

This is saving my video as 1600x1200 5fps in daytime and also in night with real time speed.

But when I do something like this

cam = cv2.VideoCapture(0)

width = 1280
height = 720
fps = 11.120

# ....

I'm getting video 1280x720 11.120fps in daytime and also in night, but in night my video getting faster! Like fast-forwarding, 1 sec takes 0.5 sec and everything in the video is moving faster.

How could I avoid this? Is it because my camera is too sh*tty and can't get faster shutter speed at night so cv2 to persist11.120 fps fast-forwarding the video?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...