# The virtual background with a custom image has an unnecessary black edge

**URL:** <https://devforum.zoom.us/t/the-virtual-background-with-a-custom-image-has-an-unnecessary-black-edge/130131>\
**Category:** Web\
**Created:** [March 19, 2025, 10:09am UTC](https://devforum.zoom.us/t/the-virtual-background-with-a-custom-image-has-an-unnecessary-black-edge/130131 "2025-03-19T10:09:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [March 19, 2025, 10:09am UTC](https://devforum.zoom.us/t/the-virtual-background-with-a-custom-image-has-an-unnecessary-black-edge/130131/1 "2025-03-19T10:09:41Z")

</div>

**Description**

The virtual background with a custom image has an unnecessary black edge. (Ratio camera view is: 16 : 9)

**Which Web Video SDK version?**  
2.1.0

**Video SDK Code Snippets**

```auto
    try {
      if (imageUrl) {
        await this.localVideoTrack.start(document.querySelector('#preview-camera-canvas'), { imageUrl: imageUrl });
      } else {
        await this.localVideoTrack.start(document.querySelector('#preview-camera-video'));
      }
    } catch (error) {
      Logger.error('[VIDEO-SDK JS] Start local preview video error', error);
      throw error;
    }

```

**Screenshots**

 ![Screenshot 2025-03-19 at 17.06.05](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/2/4/24ecdc8965104dbe352b575a92a6f3f9ea0d0afe.png)  
 ![Screenshot 2025-03-19 at 16.59.29](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/4/3/43bf61e97707ebf8e59b21b374ed228391608c5f.png)

**Device:**

- Device: Mac
- OS: MacOS 15.1
- Browser: Chrome
- Browser Version: 134.0.6998.89

---

<div class="post-metadata">

**Author:** ![ekaansh.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ekaansh.zoom/32/55004_2.png) [@ekaansh.zoom](https://devforum.zoom.us/u/ekaansh.zoom)\
**Post date:** [April 2, 2025, 12:34pm UTC](https://devforum.zoom.us/t/the-virtual-background-with-a-custom-image-has-an-unnecessary-black-edge/130131/3 "2025-04-02T12:34:45Z")

</div>

Hey @lmtruong1512  
Do you observe this in the latest version of the Video SDK? I’m unable to reproduce this in `v2.1.10`. I tried both a vertical and a horizontal image.

 ![Screenshot 2025-04-02 at 5.04.40 PM](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/b/8/b88a9a9cf1e32eb9559c1eb6b4fee5d28215c518.jpeg)

I’m using this repo: [GitHub - zoom/videosdk-web-helloworld](https://github.com/zoom/videosdk-web-helloworld)  
Here’s the code change I made:

```js
await mediaStream.startVideo({ virtualBackground: { imageUrl: "image-url" } });

```

We don’t recommend using a `<canvas>` element anymore, you can use the standard `<video-player-container>` element.

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [April 3, 2025, 3:08am UTC](https://devforum.zoom.us/t/the-virtual-background-with-a-custom-image-has-an-unnecessary-black-edge/130131/4 "2025-04-03T03:08:05Z")

</div>

@ekaansh.zoom Thank you for your response.

We switched to using the `<video-player-container>` element but still face this issue. The example above uses `mediaStream` during the meeting instead of the local video track in the preview. We noticed that the problem only occurs during the preview. Could you check if it happens in the preview as well?

---

<div class="post-metadata">

**Author:** ![ekaansh.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ekaansh.zoom/32/55004_2.png) [@ekaansh.zoom](https://devforum.zoom.us/u/ekaansh.zoom)\
**Post date:** [April 3, 2025, 1:56pm UTC](https://devforum.zoom.us/t/the-virtual-background-with-a-custom-image-has-an-unnecessary-black-edge/130131/5 "2025-04-03T13:56:58Z")

</div>

Hi @lmtruong1512

From our docs, we suggest using this pattern for previewing virtual background:

```js
  const mediaStream = client.getMediaStream();
  const vidPlayer = document.querySelector("#in-session-preview-video") as VideoPlayer
  mediaStream.previewVirtualBackground(vidPlayer, "url", false)

```

```html
  <video-player-container>
    <video-player id="in-session-preview-video"></video-player>
  </video-player-container>

```

Here is the doc: [Video SDK - web - Video](https://developers.zoom.us/docs/video-sdk/web/video/#in-session-preview)

* * *

I also tried and used the `createLocalVideoTrack` method and don’t observe the black edge on the latest VSDK release, however the quality is not as good as the suggested method above.

```js
  const localVid = ZoomVideo.createLocalVideoTrack();
  const vidPlayer = document.querySelector("#in-session-preview-video") as VideoPlayer
  await localVid.start(vidPlayer, { imageUrl: "https://images.pexels.com/photos/31410286/pexels-photo-31410286/free-photo-of-serene-view-of-tibetan-plateau-antelopes.jpeg" });

```

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [April 9, 2025, 6:48am UTC](https://devforum.zoom.us/t/the-virtual-background-with-a-custom-image-has-an-unnecessary-black-edge/130131/6 "2025-04-09T06:48:12Z")

</div>

Thanks, @ekaansh.zoom! I’ll try using `mediaStream` instead.

---

<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:** [May 9, 2025, 4:48pm UTC](https://devforum.zoom.us/t/the-virtual-background-with-a-custom-image-has-an-unnecessary-black-edge/130131/7 "2025-05-09T16:48:48Z")

</div>

Closed on May 9, 2025, 4:48pm UTC

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