trojek
trojek

Reputation: 3228

How to set video capture format in opencv using python?

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?

Upvotes: 3

Views: 3190

Answers (1)

stackuser
stackuser

Reputation: 669

Please try below line.

cap.set(8, ('M', 'J', 'P', 'G'))

Upvotes: 1

Related Questions