# Cannot get FOURCC with CAP\_MSMF as backend

**URL:** <https://forum.opencv.org/t/cannot-get-fourcc-with-cap-msmf-as-backend/20858>\
**Category:** Python\
**Tags:** windows, videoio\
**Created:** [April 21, 2025, 9:56am UTC](https://forum.opencv.org/t/cannot-get-fourcc-with-cap-msmf-as-backend/20858 "2025-04-21T09:56:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hanning\_Liu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/hanning_liu/32/11447_2.png) [@Hanning\_Liu](https://forum.opencv.org/u/Hanning_Liu)\
**Post date:** [April 21, 2025, 9:56am UTC](https://forum.opencv.org/t/cannot-get-fourcc-with-cap-msmf-as-backend/20858/1 "2025-04-21T09:56:34Z")

</div>

I’m new to programming.  
I want to see the RAW format of my laptop camera.  
So I am trying to use the python script below to print out the format, but I cannot get result with CAP\_MSMF as backend.  
I think the code `22` (which converts to `\x16\x00\x00\x00`) I got is weird. Can somebody explain about it?  
See below:

```python
import cv2

def get_camera_fourcc(camera_index=0):
    # Force using MSMF backend (recommended for Windows 10+)
    cap = cv2.VideoCapture(camera_index, cv2.CAP_MSMF)
    
    # Get FourCC code (may return integer like 22)
    fourcc_code = int(cap.get(cv2.CAP_PROP_FOURCC))
    
    # Convert to FourCC string (e.g., 'MJPG')
    fourcc_str = (
        chr((fourcc_code >> 0) & 0xFF) +
        chr((fourcc_code >> 8) & 0xFF) +
        chr((fourcc_code >> 16) & 0xFF) +
        chr((fourcc_code >> 24) & 0xFF)
    )
    
    print(f"📷 Camera index {camera_index} information:")
    print(f"🔧 Backend: {cap.getBackendName()}")
    print(f"🎞️ FourCC code: {fourcc_str} (numeric: {fourcc_code})")
    
    # Try to read a frame to check actual data format
    ret, frame = cap.read()
    if ret:
        print(f"🖼️ Image shape: {frame.shape} (H, W, C)")
        print(f"🎨 Data type: {frame.dtype}")
    else:
        print("⚠️ Failed to read frame data")
    
    cap.release()
    return fourcc_str

if __name__ == " __main__":
    camera_index = 1 # This is the HD Webcam on my Windows laptop
    fourcc = get_camera_fourcc(camera_index)
    
    if fourcc == "MJPG":
        print("✅ Camera uses MJPG (Motion-JPEG) encoding")
    elif fourcc == "YUY2":
        print("✅ Camera uses YUY2 (uncompressed YUV 4:2:2)")
    elif fourcc == "NV12":
        print("✅ Camera uses NV12 (YUV 4:2:0)")
    else:
        print(f"❓ Unknown FourCC format: {fourcc}")

```

Result:

```Python
📷 Camera index 1 information:
🔧 Backend: MSMF
🎞️ FourCC code: (numeric: 22)
🖼️ Image shape: (480, 640, 3) (H, W, C)
🎨 Data type: uint8
❓ Unknown FourCC format: 

```
