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

来源:互联网 发布:一开守望先锋网络就卡 编辑:程序博客网 时间:2024/05/16 06:47

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

askedMar 9 '14

symon6 gravatar image

updatedMar 26 '14

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 argumentVIDIOC_QUERYMENU: Invalid argumentVIDIOC_QUERYMENU: Invalid argumentVIDIOC_QUERYMENU: Invalid argumentVIDIOC_QUERYMENU: Invalid argumentVIDIOC_QUERYMENU: Invalid argumentVIDIOC_QUERYMENU: Invalid argumentTraceback (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
add a comment

2 answers

Sort by » oldestnewestmost voted
5

answeredMar 26 '14

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')

editlink

Comments

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

wibowo gravatar imagewibowo (Dec 8 '14)

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

wibowo gravatar imagewibowo (Dec 8 '14)

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 (Oct 8 '15)
add a comment
0

answeredOct 8 '15

volodia gravatar image

updatedOct 8 '15

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.

editlink
add a comment

0 0
原创粉丝点击