OpenCV Video Tutorial bug (Bug #4091)
Description
Saving a Video section
import numpy as npimport cv2
cap = cv2.VideoCapture(0)
- Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'XVID')
This line fails: cv2.VideoWriter_fourcc(*'XVID')
Workaround is to replace the entire line with:
fourcc = cv2.cv.CV_FOURCC(*'XVID')
History
Updated by Ariel Machado about 10 years ago
I checked the referred code using OpenCV 3.0.0-beta with Python 2.7.8 |Anaconda 2.1.0 (64-bit)| and is working correctly in my box (Win7 64-bit):
import numpy as np import cv2 print "OpenCV version ", cv2.__version__ cap = cv2.VideoCapture(0) # Define the codec and create VideoWriter object fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480)) while(cap.isOpened()): ret, frame = cap.read() if ret==True: frame = cv2.flip(frame,0) # write the flipped frame out.write(frame) cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break else: break # Release everything if job is finished cap.release() out.release() cv2.destroyAllWindows()
According the documentation the example is OK and this static method constructs the fourcc code of the codec to be used in the constructor:
http://docs.opencv.org/3.0-beta/modules/videoio/doc/reading_and_writing_video.html?highlight=videowriter_fourcc#cv2.VideoWriter_fourcc
What you mean by "This line fails"?
Take a look to this documentation about how to report a bug:
http://code.opencv.org/projects/OpenCV/wiki/WikiStart#Reporting-bugs
Ariel.
- % Done changed from 0 to 90
- Status changed from New to Incomplete
Updated by Steven Puttemans about 10 years ago
Checked and works like a charm here. Can you please get latest 3.0 branch and be sure your system is correctly configured?
Reopen if needed. Cleaning up documentation section for now.
- Status changed from Incomplete to Cancelled