'how to turn off decoding of mjpeg stream from webcam in windows

I am trying read full resolution JPEG frame (4k) from MJPEG camera without decoding in Python/OpenCV. i tried the method from this post Read JPEG frame from MJPEG camera without decoding in Python/OpenCV but video_capture_1.set(cv2.CAP_PROP_CONVERT_RGB, 0) made no different. I still get decoded frames. ("image type of frame1: <class 'numpy.ndarray'>" )

import numpy as np
import cv2
video_capture_1 = cv2.VideoCapture(1, cv2.CAP_DSHOW)
video_capture_1.set(cv2.CAP_PROP_CONVERT_RGB, 0)
video_capture_1.set(cv2.CAP_PROP_BUFFERSIZE, 0)
video_capture_1.set(cv2.CAP_PROP_FOURCC, 
video_capture_1.set(cv2.CAP_PROP_FPS, 10.0)
video_capture_1.set(cv2.CAP_PROP_FRAME_WIDTH, 25920)
video_capture_1.set(cv2.CAP_PROP_FRAME_HEIGHT, 19440)

if not video_capture_1.isOpened():
    print("Cannot open camera1")

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('dualcam.avi', fourcc, 30.0, size)

while True:
    video_capture_1.grab() 
    _, frame1 = video_capture_1.retrieve()  
    #print("frame1:", frame1.shape)
    print('image type of frame1:   ' + str(type(frame1)))

    if (ret1) :
        out.write(frame1)
        cv2.imshow('recording', frame1)
        break
    if cv2.waitKey(1) & 0xFF == ord('e'):
        break
video_capture_1.release()
out.release()
cv2.destroyAllWindows

it did not work. very likely because window don't give you the trun off choice anymore. it started from 2016 https://social.msdn.microsoft.com/Forums/en-US/9d6a8704-764f-46df-a41c-8e9d84f7f0f3/mjpg-encoded-media-type-is-not-available-for-usbuvc-webcameras-after-windows-10-version-1607-os?forum=mediafoundationdevelopment also i coudnot use FFmpeg to connect to my webcam in windows.as windows use only directshow for usb webcam anyway to get around?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source