Ask Your Question
0

AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

asked 2014-03-08 13:35:28 -0600

symon6 gravatar image

updated 2014-03-26 07:10:06 -0600

berak gravatar image

I am trying to capture video throught this tutorial: http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html but when I try to use the last source code I give this error message:

python record_video.py 
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
Traceback (most recent call last):
  File "record_video.py", line 7, in <module>
    fourcc = cv2.VideoWriter_fourcc()
AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

Sorry for my English :)

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
6

answered 2014-03-26 05:47:38 -0600

pjthakkar3192 gravatar image

actually i was also stuck to this code, instead of this code fourcc = cv2.videowriter_fourcc(*'XVID')

write this code it works fine with me fourcc = cv2.cv.CV_FOURCC(*'XVID')

edit flag offensive delete link more

Comments

where you know this code " fourcc = cv2.cv.CV_FOURCC(*'XVID')" ? sory, I have much to learn from you. #newbie

wibowo gravatar imagewibowo ( 2014-12-08 08:43:37 -0600 )edit

where You can code "fourcc = cv2.cv.CV_FOURCC(*'XVID')"? Sory newbie, I have much to learn from you.

wibowo gravatar imagewibowo ( 2014-12-08 08:46:17 -0600 )edit

http://answers.opencv.org/question/44...

It depends on OpenCV version you use.

Want you to know where it said which use? http://opencv-python-tutroals.readthe... This is lastest (for 3.0 which is in-development ;) ) and there are descriptions about settings (keyword - FourCC)

When want to see for 2.4.* do sth like this:

  1. copy repository from GitHub (be sure you have git)
  2. git checkout 2.4.9
  3. grep -rni xvid

You will see sth like: ... modules/highgui/src/cap_gstreamer.cpp:474: encs[CV_FOURCC('X','V','I','D')]=(char*)"xvidenc"; ... then see: modules/highgui/doc/reading_and_writing_images_and_video.rst

Have fun :)

volodia gravatar imagevolodia ( 2015-10-08 07:32:19 -0600 )edit
0

answered 2015-10-08 08:14:42 -0600

volodia gravatar image

updated 2015-10-08 08:22:27 -0600

To be sure that you have answer for your question.

>> import cv2
>> cv2.__version__
2.4.9.1
>>> fourcc = cv2.VideoWriter_fourcc()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

That means there is no cv2.VideoWriter_fourcc() because it exsist from 3.0 ver. but you using 2.4.9.1 :)

When you use that version you should change that for fourcc = cv2.cv.CV_FOURCC(*'XVID') like @pjthakkar3192 said before. (if you want to support 2.4.* and 3.* ver of OpenCV just check if func is callable - callable(cv2.cv.CV_FOURCC))

Best regards.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-08 13:35:28 -0600

Seen: 41,590 times

Last updated: Oct 08 '15