Python OpenCV2 cv2.cv_fourcc not working with VideoWriter


Question

As the title states, when I run the cv2.videowriter function I get 'module' object has no attribute CV_FOURCC.

Code:

# Creates a video file from webcam stream
import cv2

Create test window
cv2.namedWindow("cam_out", cv2.CV_WINDOW_AUTOSIZE)

# Create vid cap object
vid = cv2.VideoCapture(1)


# Create video writer object
vidwrite = cv2.VideoWriter(['testvideo', cv2.CV_FOURCC('M','J','P','G'), 25, 
               (640,480),True])
1
12
9/30/2016 10:07:06 AM

Kind of late to the party, but if anyone needs it for newer versions of opencv2, then the command is:

cv2.VideoWriter_fourcc(c1, c2, c3, c4)
28
2/19/2014 1:22:14 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon