MathewSachin/Captura · error · NotSupportedException
Unknown Grabber Media Format
Error message
Unknown Grabber Media Format
What it means
Thrown by CaptureWebcam (src/Captura.Windows/Webcam/CaptureWebcam.cs:465) as NotSupportedException when the DirectShow sample grabber's connected media type is not FormatType.VideoInfo or has a zero formatPtr. The code only handles the VideoInfo header layout, so any camera that negotiates VideoInfo2 (or another format type) is rejected.
Source
Thrown at src/Captura.Windows/Webcam/CaptureWebcam.cs:465
Marshal.ThrowExceptionForHR(hr);
// Make the video window visible, now that it is properly positioned
hr = _videoWindow.put_Visible(OABool.True);
if (hr < 0)
Marshal.ThrowExceptionForHR(hr);
_isPreviewRendered = true;
didSomething = true;
var media = new AMMediaType();
hr = _sampGrabber.GetConnectedMediaType(media);
if (hr < 0)
Marshal.ThrowExceptionForHR(hr);
if (media.formatType != FormatType.VideoInfo || media.formatPtr == IntPtr.Zero)
throw new NotSupportedException("Unknown Grabber Media Format");
_videoInfoHeader = (VideoInfoHeader)Marshal.PtrToStructure(media.formatPtr, typeof(VideoInfoHeader));
Marshal.FreeCoTaskMem(media.formatPtr);
media.formatPtr = IntPtr.Zero;
}
if (didSomething)
_actualGraphState = GraphState.Rendered;
}
/// <summary>
/// Setup and start the preview window if the user has
/// requested it (by setting PreviewWindow).
/// </summary>
void StartPreviewIfNeeded()
{
// Render preview View on GitHub (pinned to 3fdf41529b)
Solutions
- Add a branch that handles FormatType.VideoInfo2 by reading VideoInfoHeader2 and deriving the equivalent VideoInfoHeader.
- Force the grabber input pin to negotiate a VideoInfo media type (set AMMediaType before connection).
- Try a different resolution or pixel format on the camera that is offered as VideoInfo.
- Test with another webcam to confirm it is media-type-specific.
Example fix
// before
if (media.formatType != FormatType.VideoInfo || media.formatPtr == IntPtr.Zero)
throw new NotSupportedException("Unknown Grabber Media Format");
_videoInfoHeader = (VideoInfoHeader)Marshal.PtrToStructure(media.formatPtr, typeof(VideoInfoHeader));
// after
if (media.formatType == FormatType.VideoInfo && media.formatPtr != IntPtr.Zero)
_videoInfoHeader = (VideoInfoHeader)Marshal.PtrToStructure(media.formatPtr, typeof(VideoInfoHeader));
else if (media.formatType == FormatType.VideoInfo2 && media.formatPtr != IntPtr.Zero)
_videoInfoHeader = ((VideoInfoHeader2)Marshal.PtrToStructure(media.formatPtr, typeof(VideoInfoHeader2))).ToVideoInfoHeader();
else
throw new NotSupportedException($"Unsupported grabber media format: {media.formatType}"); Defensive patterns
Strategy: fallback
Validate before calling
// before connecting the grabber, enumerate offered media types and prefer VideoInfo var preferred = offered.FirstOrDefault(m => m.formatType == FormatType.VideoInfo); if (preferred != null) pin.Connect(preferred);
Type guard
static bool SupportsVideoInfo(AMMediaType m)
=> m.formatType == FormatType.VideoInfo && m.formatPtr != IntPtr.Zero; Try / catch
try { /* configure grabber */ }
catch (NotSupportedException e) when (e.Message.Contains("Grabber Media Format")) { /* add VideoInfo2 handling or switch camera */ } Prevention
- Handle FormatType.VideoInfo2 in addition to VideoInfo before throwing.
- Enumerate the camera pin's offered media types and force a VideoInfo subtype.
- Test across multiple webcams and resolutions to confirm format dependence.
When it happens
Trigger: After ISampleGrabber.GetConnectedMediaType, media.formatType != FormatType.VideoInfo or media.formatPtr == IntPtr.Zero. Webcams commonly expose VideoInfo2 (carrying interlacing/anamorphic info) instead of VideoInfo, especially at certain resolutions or on newer drivers.
Common situations: A camera that only offers VideoInfo2 at the chosen resolution; a UVC driver preferring VideoInfo2; requesting a resolution/pixel format that the camera satisfies via VideoInfo2; a disconnected/zero-format pin.
Related errors
- Desktop Duplication is not supported on this system.\nIf you
- There is already the maximum number of applications using th
- Failed to acquire next frame: {acquireResult.Result.Code}
- FFmpeg could not be found. Please download using the in-buil
- An Error Occurred with FFmpeg, Exit Code: {ExitCode}.\nSee F
AI-assisted analysis of MathewSachin/Captura@3fdf41529b (2026-08-13).
Data as JSON: /api/errors/079d7ad683b110ce.
Report an issue: GitHub.