Using YUV2 or MPEG format does not work

Alok Chander 30 Reputation points

I am using the below program to capture frames from the video stream using the sample grabber. When I use the MEDIASUBTYPE_RGB32 the images show up and I can open them. However when I use MEDIASUBTYPE_YUV2 or MEDIASUBTYPE_MJPG then the saved image does not open(The photos app says this format is not supported). Can someone explain how I can get this to work with other formats? I also don't understand why RGB32 works when the camera does not even report supporting it. It only reports MJPG and YUV2 as being supported.sample.txt

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,352 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,441 questions
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 10,706 Reputation points Microsoft Vendor

    As I said in another question, the file including its extension written by your SampleGrabberCallback::BufferCB is invalid, although it's valid for MEDIASUBTYPE_RGB32 in .bmp file. I found the related thread which said

    You don't use a BITMAPINFOHEADER for a JPEG image, and you certainly don't save them to a .BMP. It's a JPEG. You just copy the bits to file and make the extension .JPG. As long as the first two bytes are FF D8, that should be all it takes.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful