# Error when switching from virtual camera back to real camera — "CAN\_NOT\_FIND\_CAMERA"

**URL:** <https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921>\
**Category:** Web\
**Created:** [June 12, 2025, 2:53am UTC](https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921 "2025-06-12T02:53:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![namlv](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/namlv/32/51610_2.png) [@namlv](https://devforum.zoom.us/u/namlv)\
**Post date:** [June 12, 2025, 2:53am UTC](https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921/1 "2025-06-12T02:53:24Z")

</div>

**Description**

I’m trying to implement a virtual camera by overriding `MediaDevices.prototype.enumerateDevices` and `MediaDevices.prototype.getUserMedia`. I’m able to successfully switch to the virtual camera within Zoom. However, when I attempt to switch back to the physical (built-in) camera, I receive the following error. I have confirmed that the device ID I’m trying to switch to is valid — it was obtained from a call to `enumerateDevices()` .

**Browser Console Error**

```auto
Error: {"type":"CAN_NOT_FIND_CAMERA","reason":"cannot find target camera"}

```

**Which Web Video SDK version?**  
2.1.0

**Video SDK Code Snippets**  
Here are the override implementations I’m using for `enumerateDevices` and `getUserMedia` to simulate a virtual camera:

```auto
const enumerateDevicesFn = navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);
const getUserMediaFn = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);

MediaDevices.prototype.enumerateDevices = async function () {
    const res = await enumerateDevicesFn.call(navigator.mediaDevices);
    let dv = VIRTUAL_DEVICE;
    dv = { ...dv, toJSON: () => dv }; // Ensure toJSON method is available
    res.push(dv);
    return res
}

MediaDevices.prototype.getUserMedia = async function (...args) {
    if (args.length && args[0].video && args[0].video.deviceId) {
        if (
            args[0].video.deviceId === VIRTUAL_DEVICE.deviceId ||
            args[0].video.deviceId.exact === VIRTUAL_DEVICE.deviceId
        ) {
            const constraints = {
                video: { ...(args?.video ?? {}) },
                audio: false
            }
            const res = await getUserMediaFn.call(
                navigator.mediaDevices,
                constraints
            )

            const canvas = document.getElementById(AVATAR_CANVAS_ID)
            if (res && canvas) {
                return canvas.captureStream(30)
            }
        }
    }

    const res = await getUserMediaFn.call(navigator.mediaDevices, ...args);
    return res;
}

```

**To Reproduce**

1. Join a Zoom Video SDK session.
2. Start the session using a real physical camera (works as expected).
3. Switch to the virtual camera (also works).
4. Attempt to switch back to the physical camera.
5. Observe the error:

```auto
Error: {"type":"CAN_NOT_FIND_CAMERA","reason":"cannot find target camera"}

```

**Screenshots**  
If applicable, add screenshots to help explain your problem.

**Device :**

- Device: MacBook Pro (Apple Silicon)
- OS: macOS (Sonoma)
- Browser: Chrome
- Browser Version: 137.0.6482.114 (Official Build) (arm64)

**Session ID :**  
`4OoNSCdnRRSq3GeJfQzaxA==`

---

<div class="post-metadata">

**Author:** ![namlv](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/namlv/32/51610_2.png) [@namlv](https://devforum.zoom.us/u/namlv)\
**Post date:** [June 12, 2025, 2:54am UTC](https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921/2 "2025-06-12T02:54:42Z")

</div>

Hi @vic.yang,  
Could you please help take a look at this issue when you have a moment? I’d really appreciate your insights.

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [June 12, 2025, 6:39am UTC](https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921/3 "2025-06-12T06:39:53Z")

</div>

Hi @namlv

Thanks for your feedback.

We haven’t actually encountered cases where `enumerateDevices` and `getUserMedia` were overridden, but when the error ‘cannot find target camera’ is returned, it’s usually because the provided `deviceId` doesn’t match any available devices.

We will evaluate this scenario and improve the method in the next version.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![namlv](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/namlv/32/51610_2.png) [@namlv](https://devforum.zoom.us/u/namlv)\
**Post date:** [June 12, 2025, 7:02am UTC](https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921/4 "2025-06-12T07:02:04Z")

</div>

@vic.yang Thank you for your response

I have already validated that the `deviceId` is correct before switching. In fact, I initially started the session using that same `deviceId` before switching to the virtual camera.

Let me briefly describe how I implemented this:  
I first call `getUserMedia` with the real device’s `deviceId` and render its stream to a `<canvas>` element. Then, my virtual camera pulls video from that canvas as its source.

Before switching back to the real camera, I make sure to stop the stream from the virtual source and remove the canvas element from the DOM.

However, when I attempt to switch back using `client.switchCamera(deviceId)`, I get the following error:

```auto
{ "type": "CAN_NOT_FIND_CAMERA", "reason": "cannot find target camera" }

```

Interestingly, if I _stop_ the current camera and _start_ a new stream using `client.startVideo(deviceId)` instead of switching, it works correctly.

Do you have any suggestions on how to make `switchCamera()` work in this setup, or any best practices to avoid this issue?

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [June 12, 2025, 7:25am UTC](https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921/5 "2025-06-12T07:25:53Z")

</div>

Hi @namlv

> Interestingly, if I _stop_ the current camera and _start_ a new stream using `client.startVideo(deviceId)` instead of switching, it works correctly.

Yes.

We have encountered an edge case where overriding `enumerateDevices` and `getUserMedia` causes `switchCamera` to fail.

Currently, using `stopVideo` followed by `startVideo({ cameraId })` serves as a workable workaround.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![namlv](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/namlv/32/51610_2.png) [@namlv](https://devforum.zoom.us/u/namlv)\
**Post date:** [June 12, 2025, 7:31am UTC](https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921/6 "2025-06-12T07:31:42Z")

</div>

Thanks again for your time and support!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [June 12, 2026, 7:31am UTC](https://devforum.zoom.us/t/error-when-switching-from-virtual-camera-back-to-real-camera-can-not-find-camera/133921/7 "2026-06-12T07:31:46Z")

</div>

Closed on June 12, 2026, 7:31am UTC

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
