Hi @Tom JD1 Xue
Thank you for posting your question in the Microsoft Q&A forum.
Your understanding is mostly correct. The issue occurs because Microsoft Teams selects an MJPG path that only supports a single active instance. When this happens, the Windows Camera Frame Server can’t deliver frames to your SharedReadOnly session, so your TryAcquireLatestFrame() call keeps returning null.
When you initialize MediaCapture with SharingMode set to SharedReadOnly, Windows allows multiple apps to access the same camera at the same time. This mode is designed for scenarios where your app needs to run alongside another app such as Microsoft Teams. You can’t change camera settings in this mode, but you should still be able to receive frames unless something in the camera pipeline is blocking them.
If TryAcquireLatestFrame() continually returns null, it usually means that no frames are available or the reader isn’t actually receiving any data. This can happen when another application is using the camera in a way that prevents the Frame Server from sharing the stream. Microsoft recommends handling the FrameArrived event and reading frames inside that handler, always checking for null. If the event fires but no frame is delivered, the pipeline may be blocked.
Whether Teams choosing MJPG prevents your app from receiving frames depends on whether the Windows Camera Frame Server is active. The Frame Server is responsible for sharing camera access across apps. If Teams or the camera driver bypasses the Frame Server by locking a hardware MJPG decoder or using a single-instance MJPG pin, your app may be blocked from receiving frames.
To improve compatibility and avoid MJPG-related issues, consider the following steps:
-Use an uncompressed format like NV12 or YUY2. Even if Teams uses MJPG, you can often open a parallel NV12 or YUY2 stream through the Frame Server. Select NV12 or YUY2 explicitly from the SupportedFormats list of your MediaFrameSource to avoid binding to MJPG hardware decoding.
Reference: Process media frames with MediaFrameReader - Windows apps | Microsoft Learn.
-Lower your requested resolution or frame rate. Some camera drivers only support concurrent streams at reduced resolutions or when one stream uses NV12 or YUY2. Use camera profiles to find combinations that support concurrent access and initialize your app with one of those profiles.
References:
- Discover and select camera capabilities with camera profiles - Windows apps | Microsoft Learn.
- MediaCaptureVideoProfile Class (Windows.Media.Capture) - Windows apps | Microsoft Learn.
-Avoid using hardware MJPG decoding. If your pipeline uses Media Foundation transforms, disable hardware decoding so the system uses software decoding instead. This allows multiple apps to decode frames simultaneously.
For Source Reader or Sink Writer pipelines, set MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS to false.
For MediaCapture, follow the guidance on disabling hardware transforms.
Note: Microsoft is providing this information as a convenience to you. These sites are not controlled by Microsoft, and Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please ensure that you fully understand the risks before using any suggestions from the above link.
Reference: MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS attribute (Mfreadwrite.h) - Win32 apps | Microsoft Learn.
-Start your SharedReadOnly reader before Teams opens the camera. This can sometimes encourage Windows to keep the Frame Server path active. It’s not guaranteed, but it’s a quick test that might help.
Reference: MediaCaptureInitializationSettings.SharingMode Property (Windows.Media.Capture) - Windows apps | Mi…
-Update your camera driver or switch to the Windows inbox UVC driver. Many concurrency issues are caused by vendor-specific drivers or MJPG paths that rely on single-instance hardware transforms.
-If your scenario allows, plug in or emulate a virtual camera driver that mirrors the physical camera. you can use a virtual camera driver that mirrors the physical camera. One instance can feed Teams (MJPG), while another feeds your processing pipeline (NV12).
I hope this information is helpful.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.