3

I have a webcam which supports YUYV (raw) and MJPEG (compressed) formats. When I capture video stream - cap = cv2.VideoCapture(0), openCV takes YUYV as default.

I want to use MJPEG (MJPG). I found here that it is possible. I try to set it by command: cap.set(7, ('M', 'J', 'P', 'G')), but it doesn't work. How can I choose which video format I want to get in OpenCV?

1 Answer 1

1

Please try below line.

cap.set(8, ('M', 'J', 'P', 'G'))
Sign up to request clarification or add additional context in comments.

1 Comment

Just in case somebody comes over this: 8 is the numeric representation for cv.CAP_PROP_FORMAT like 7 is the one for cv.CAP_PROP_FRAME_COUNT These are defined in VideoCaptureProperties (as of now reachable via docs.opencv.org/4.x/d4/d15/…)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.