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

旧城等待, 2022-07-14 13:27 337阅读 0赞

AttributeError: ‘module’ object has no attribute ‘VideoWriter_fourcc’

  • VideoWriter_fourcc
  • python

asked Mar 9 ‘14

symon6 gravatar image

symon6
1 ●1 ●1 ●1

updated Mar 26 ‘14

berak gravatar image

berak
13969 ●2 ●65 ●209

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:

  1. 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

add a comment

2 answers

Sort by » oldest newest most voted

5

answered Mar 26 ‘14

pjthakkar3192 gravatar image

pjthakkar3192
51 ●1 ●2

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 link

Comments

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

wibowo gravatar image wibowo (Dec 8 ‘14)

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

wibowo gravatar image wibowo (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 image volodia (Oct 8 ‘15)

add a comment

0

answered Oct 8 ‘15

volodia gravatar image

volodia
16 ●5

updated Oct 8 ‘15

To be sure that you have answer for your question.

  1. >> import cv2
  2. >> cv2.__version__
  3. 2.4.9.1
  4. >>> fourcc = cv2.VideoWriter_fourcc()
  5. Traceback (most recent call last):
  6. File "<stdin>", line 1, in <module>
  7. 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 link

add a comment

发表评论

表情:
评论列表 (有 0 条评论,337人围观)

还没有评论,来说两句吧...

相关阅读