When a Windows capture application reports “No matching media type for pixel format,” first identify which layer wrote that message. An SDK's text is not a complete Media Foundation diagnosis. Record the failed call and HRESULT, the selected device and stream, and the requested format. Then compare that request with the source's actual advertised types. This separates an unsupported request from a conversion failure or a source that cannot start.
The steps below apply when the application really uses a Windows media source or Source Reader. A camera opened through a GenTL producer follows its own feature and stream interface, unless a separate driver or adapter exposes it to Windows capture. Use the GenICam enumeration diagnosis for that path.
Decode the integer without reversing the conclusion
The Windows FourCC integer for YUY2 is 0x32595559, and its subtype GUID is 32595559-0000-0010-8000-00AA00389B71. The integer's little-endian byte sequence spells YUY2. The Windows FourCC definition explains this convention.
This hardware-independent Python example makes the distinction explicit:
def windows_fourcc_text(value):
if not isinstance(value, int) or not 0 <= value <= 0xFFFFFFFF:
raise ValueError("FourCC must be an unsigned 32-bit integer")
raw = value.to_bytes(4, "little")
return "".join(chr(b) if 32 <= b <= 126 else "." for b in raw)
assert int.from_bytes(b"YUY2", "little") == 0x32595559
assert windows_fourcc_text(0x32595559) == "YUY2"
assert windows_fourcc_text(0x59555932) == "2YUY"
If a log contains 59555932, inspect the producer's formatting code or compare it with a known format. It may print a character-order representation. Do not copy that string into a Windows subtype field and assume the two representations are interchangeable. Preserve the full GUID as well: not every subtype is safely identified by interpreting its first eight hex digits as printable characters.
Establish what the pixels mean
The Media Foundation subtype table identifies YUY2 as packed YUV colour with 4:2:2 sampling. That label does not establish a depth unit, invalid-pixel value or camera calibration model.
For a device-specific depth transport, obtain the exact SDK's definition of the payload before interpreting it. Record the storage type, stride, distance scale and invalid-value encoding alongside the subtype. Keep display conversion separate from measurement data; a colour conversion applied to a depth container can destroy its meaning. The depth-map display guide explains how to preserve numerical values while creating a preview.
Enumerate the native formats on the selected source
With an IMFSourceReader, call GetNativeMediaType for each relevant stream and increasing type index. MF_E_NO_MORE_TYPES ends that stream's list; MF_E_INVALIDSTREAMNUMBER identifies an invalid stream index. A different failure is an error to record, not an empty list to ignore.
For every returned type, log MF_MT_MAJOR_TYPE, MF_MT_SUBTYPE, MF_MT_FRAME_SIZE and MF_MT_FRAME_RATE, together with stream and type indices. Retain frame rate as a numerator/denominator pair: 30000/1001 and 30/1 are different requests. Record additional type attributes rather than rebuilding a type from four fields and discarding the rest.
The following is pseudocode for the diagnostic loop, not a complete C++ capture program:
for each stream index belonging to this source:
type_index = 0
repeat:
hr, media_type = GetNativeMediaType(stream_index, type_index)
if hr is MF_E_NO_MORE_TYPES: finish this stream
if hr failed: record hr and stop this stream's diagnostic
record stream_index, type_index and media_type attributes
release media_type
type_index += 1
Do not assume stream 0 is depth or that colour and depth belong to the same media source. Label the source identity as well as its stream number. A useful comparison log contains one row from the working preview and one from the failing request, captured in the same run.
Start native, then add conversion
Choose an enumerated native type for the intended stream. Pass that type to SetCurrentMediaType, check the result, and read back the current type. The Source Reader's output type may differ from the source's native type when a supported conversion is used.
First establish acquisition without adding a conversion. Then add the output format your processing pipeline needs. This gives two separate checkpoints: whether the device can produce the native stream, and whether the configured reader can deliver the converted output.
| Result from the failing call | Next diagnostic |
|---|---|
MF_E_INVALIDSTREAMNUMBER |
Verify the source and stream index |
MF_E_INVALIDMEDIATYPE |
Compare the requested output with native types and supported conversion |
MF_E_TOPO_CODEC_NOT_FOUND |
Check the required decoder and native subtype |
MF_E_INVALIDREQUEST |
Resolve pending sample requests before changing the type |
| Type accepted but capture fails | Record the start/read error separately; test a single stream |
A listed type is not a promise that every later operation succeeds. Avoid replacing all failures with the same “unsupported format” message; keep the HRESULT and operation name in the log.
Calculate payload, then measure delivery
For an example tightly packed YUY2 image, two pixels occupy four bytes. A 640 by 480 stream at 30 frames per second therefore has this image payload:
These decimal MB/s values exclude transport overhead and any padding. For captured buffers, use the actual stride and sample length when they differ from the tightly packed assumption. Compressed formats need measured sample sizes instead of this fixed bytes-per-pixel calculation.
Do not turn a chosen percentage of the bus's nominal rate into a universal camera limit. Test one device, then add the next while recording negotiated bus speed, delivered frames, gaps and application load. A different socket can still share the same controller. The USB hub bandwidth guide provides the next diagnostic path when combined capture degrades.
Recover from a reproducible state
Save the format list and version information before changing drivers. Close other capture applications, reopen the source in a fresh process, and test one native stream. Compare the same device in its documented utility. If both fail, investigate the connection, driver and firmware combination; if only your application fails, compare source selection, type attributes and request ordering first.
Use the device's documented recovery steps when a reinstall is necessary. Do not infer a stale descriptor cache from one mismatch message, or delete a driver package simply because colour preview and depth capture behave differently.
Finish with a reproducible record: device identity, source and stream index, native type, selected output type, HRESULTs and a short capture log. Keep that record before adding more streams or processing. For a new system, the camera configurator and 3D sensors category help narrow hardware requirements; verify the intended Windows or SDK capture interface separately.
Questions
What is the Windows FourCC integer for YUY2?
It is 0x32595559. Its little-endian bytes are 59 55 59 32, which spell YUY2. The corresponding subtype GUID starts 32595559. A log printing 59555932 may display characters in another order; check how that SDK formats the number instead of treating it as the Windows integer.
Does a YUY2 stream contain depth measurements?
The standard YUY2 subtype describes packed YUV colour. Interpret it as depth only when the exact device and SDK documentation defines that transport convention, pixel layout, scale and invalid-value encoding. A familiar FourCC alone cannot establish any of those properties.
Can a listed native media type still fail to open?
Yes. A valid format choice is only one condition. Stream identity, pending requests, source state, driver behaviour and concurrent use still matter. Keep the HRESULT from the actual failing call, then compare a minimal single-stream capture with the full application.
How many 640 by 480 YUY2 streams fit on USB 2.0?
At 30 frames per second, one tightly packed stream carries 18.432 MB/s before transport overhead; two carry 36.864 MB/s. Neither number alone establishes how many streams a controller accepts. Test the actual devices together, recording negotiated speed, frame delivery and errors.
Should I uninstall the camera driver first?
Start with a fresh application instance, a single source and the native format list. Compare the camera's own capture utility and record driver and firmware versions. Follow the device's documented recovery process if these disagree; a mismatch message alone does not justify deleting a driver package.
Corrections
- Corrected the Windows YUY2 FourCC byte order, separated native media types from output conversion, and replaced unsupported depth-format and USB-capacity claims with documented checks and a payload calculation.