Ask Your Question
0

cv2.VideoWriter.write is doing nothing

asked 2013-06-19 00:30:35 -0500

harvey gravatar image

Hi, I am using python 2.7 with cv2 to record the video to file. My code is creating the file but its size is not updating it is always 0KB

Below is how I am trying

while myloop:

     sec = time.time()
     status,frame = cap.read()
     cv2.imshow("My Frame", frame)
     writer = cv2.VideoWriter(vidDir, fourcc, 30, (width,height))
     writer.write(frame)

it looks like cv2.VideoWriter.write is doing nothing. Can someone please help I want to capture the camera frames into a video file.

Thank you. harvey

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-06-19 01:15:13 -0500

AMP gravatar image

You should write this part out of Loop

writer = cv2.VideoWriter(vidDir, fourcc, 30, (width,height))

because it construct a new video file at each iteration.

edit flag offensive delete link more

Comments

oooh ofc. it's overwriting the thing in each frame ;)

berak gravatar imageberak ( 2013-06-19 01:16:50 -0500 )edit

But still it is not writing to the file.

harvey gravatar imageharvey ( 2013-06-19 01:28:19 -0500 )edit

Do I need to save and exit gracefully to save my frames to the video file, but the size of the video file is not changing even after writing writer = cv2.VideoWriter(vidDir, fourcc, 30, (width,height)) outside the loop

harvey gravatar imageharvey ( 2013-06-19 01:32:26 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-06-19 00:30:35 -0500

Seen: 818 times

Last updated: Jun 19 '13