Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python OpenCV2 cv2.cv_fourcc not working with VideoWriter

Tags:

python

opencv

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])
like image 246
user2197517 Avatar asked Mar 23 '13 07:03

user2197517


People also ask

How to write to a video using OpenCV in Python?

In this article, we will discuss how to write to a video using OpenCV in Python. Import the required libraries into the working space. Read the video on which you have to write. Create a output file using cv2.VideoWriter_fourcc () method output = cv2.VideoWriter (“path”,cv2.VideoWriter_fourcc (*’MPEG’),30, (1080,1920))

Does Python-OpenCV videowrite write video?

python - OpenCV videowrite doesn't write video - Stack Overflow I used the following page from OpenCV 3.0.0 tutorial: Tutorial in docs When I tried to use the example that saves videos, it doesn't work. It displays the content from the webcam, and also creates ... Stack Overflow About Products For Teams

How many code examples of CV2 Video writer are there?

The following are 30 code examples of cv2.VideoWriter_fourcc () . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cv2 , or try the search function .

How do I edit a video in CV2 output?

output = cv2.VideoWriter (“path”,cv2.VideoWriter_fourcc (*’MPEG’),30, (1080,1920)) Then edit the frames of the video by adding shapes to it (for the example given here, the same can be applied to any other technique.).


1 Answers

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)
like image 128
cgf Avatar answered Oct 13 '22 00:10

cgf