Skip to content Skip to sidebar Skip to footer

How To Make Work Opencv With Ffmpeg Driver

I have a camera on my linuxbox it is working well: # $ ls -al /dev/video* # crw-rw----+ 1 root video 81, 0 janv. 8 16:13 /dev/video0 # crw-rw----+ 1 root video 81, 1 janv. 8 16:1

Solution 1:

Is FFMPEG used for capture from camera by OpenCV? I think it's for files (or streams), because VideoCapture is used both for camera and for files/streams.

On my Windows setup FFMPEG used as interface for capture from camera also doesn't work (but e.g. CAP_DSHOW works), while as a codec for files it reads a frame:

cap = cv2.VideoCapture("..\\ooo.mp4", apiPreference=cv2.CAP_FFMPEG) # OK>>> print(cv2.VideoCapture(0, apiPreference=cv2.CAP_FFMPEG).isOpened())
False>>> print(cv2.VideoCapture(0, apiPreference=cv2.CAP_DSHOW).isOpened())
Trueimport cv2
# cap = cv2.VideoCapture(0, apiPreference=cv2.CAP_FFMPEG) # prints "ERROR"
cap = cv2.VideoCapture(0, apiPreference=cv2.CAP_DSHOW)  # OK, shows an image
ret, fr = cap.read()
if ret: cv2.imshow("FR", fr)
else: print("ERROR")
cv2.waitKey(0)

See also: https://trac.ffmpeg.org/wiki/Capture/Webcam

"Linux

Uses the video4linux2 (or simply v4l2) input device to capture live input such as from a webcam. See the v4l2 input device documentation for more information. "

For Windows FFMPEG is mentioned to use DirectShow as in my test:

>Windows>dshow>
>Uses the dshow (DirectShow) input device which is the preferred option for>Windows users.

Post a Comment for "How To Make Work Opencv With Ffmpeg Driver"