# Possible to put video in video element instead of canvas

**URL:** <https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465>\
**Category:** Video SDK\
**Tags:** video-sdk\
**Created:** [April 8, 2024, 5:29pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465 "2024-04-08T17:29:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tylertyler](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tylertyler/32/58198_2.png) [@tylertyler](https://devforum.zoom.us/u/tylertyler)\
**Post date:** [April 8, 2024, 5:29pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/1 "2024-04-08T17:29:10Z")

</div>

**Video SDK Type and Version**  
1.10.7

**Description**  
Is it possible to show remote videos in their own video element instead of on a canvas? I want to do this for layout and UI purposes. I want to mask the video inside of a circle or rectangle but I do not know the absolute values in pixels of the mask size so I cannot use the maskoption in the stream.

---

<div class="post-metadata">

**Author:** ![will.ezrine](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.ezrine/32/56999_2.png) [@will.ezrine](https://devforum.zoom.us/u/will.ezrine)\
**Post date:** [April 8, 2024, 5:49pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/2 "2024-04-08T17:49:09Z")

</div>

Hi @tylertyler,

Thank you for your post!

With version [1.10.7](https://developers.zoom.us/changelog/video-sdk/web/1.10.7), developers can use the [attachVideo](https://marketplacefront.zoom.us/sdk/custom/web/modules/Stream.html#attachVideo) function. The attachVideo function allows developers to render videos as individual elements, rather than on a canvas. Please follow the “Individual HTML Elements” section of the [Start Video](https://developers.zoom.us/docs/video-sdk/web/video/#start-video) documentation to achieve what you are looking for.

Let me know if I can be of any further assistance.

Best,  
Will

---

<div class="post-metadata">

**Author:** ![tylertyler](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tylertyler/32/58198_2.png) [@tylertyler](https://devforum.zoom.us/u/tylertyler)\
**Post date:** [April 8, 2024, 6:10pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/3 "2024-04-08T18:10:00Z")

</div>

I must be doing something wrong then because I’m using attachVideo, I pass it a VideoPlayer element and the remote video is still being rendered in a canvas.

Can you see any issues here?

My code (react):

```auto
<video-player-container>
    <video-player ref={videoPlayerRef} />
</video-player-container>
...
await zoomClient.getMediaStream().attachVideo(userId, VideoQuality.Video_720P, videoPlayerRef.current);

```

Output on the page:

```auto
<video-player-container>
    #shadow-root
    <canvas /> // this is where the video display is
</video-player-container>

```

---

<div class="post-metadata">

**Author:** ![will.ezrine](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.ezrine/32/56999_2.png) [@will.ezrine](https://devforum.zoom.us/u/will.ezrine)\
**Post date:** [April 8, 2024, 8:48pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/4 "2024-04-08T20:48:59Z")

</div>

Hi @tylertyler,

A few asks:

1. Could you share steps to reproduce?
2. Can you share a screenshot of the DOM itself?

Thanks,  
Will

---

<div class="post-metadata">

**Author:** ![tylertyler](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tylertyler/32/58198_2.png) [@tylertyler](https://devforum.zoom.us/u/tylertyler)\
**Post date:** [April 8, 2024, 10:26pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/5 "2024-04-08T22:26:23Z")

</div>

Here are stripped down components that deal with the videos for my app:

```auto
interface ParticipantListProps {
	currentParticipantList: number[]
}

const ParticipantList: FunctionalComponent<Props> = ({
	currentParticipantList
}: ParticipantListProps) => {
	const buildParticipantList = () => {

		return currentParticipantList.map((identity: number) => {
			return <Participant key={identity} participantId={identity} />
		})
	};

	const participants = useMemo(buildParticipantList, [
		currentParticipantList,
	]);

	return (
		<video-player-container>
			{participants}
		</video-player-container>
	);
};

interface ParticipantProps {
	currentParticipantList: number[]
}

const Participant: FunctionalComponent<ParticipantProps> = ({
	identity
}: ParticipantProps) => {

	return (
		<div>
			<div>
				<Track key={participantId} userId={participantId} />
			</div>
		</div>
	);
};

interface TrackProps {
	userId: number;
}

const Track: FunctionalComponent<TrackProps> = ({
	userId,
}: TrackProps) => {
	const videoPlayerRef = useRef();

	useEffect(() => {
		if (videoPlayerRef.current) {
			attachVideoStream();
		}

		return detachVideoStream;
	}, [videoPlayerRef]);

	async function attachVideoStream() {
		try {
			const user = await zoomClient.getUser(userId);
			if (user && user.bVideoOn) {
				await zoomClient
					.getMediaStream()
					.attachVideo(
						userId,
						VideoQuality.Video_720P,
						videoPlayerRef.current,
					);
			} else {
				console.log('user is not sharing');
			}
		} catch (e) {
			console.log('error attaching video stream', e);
		}
	}

	async function detachVideoStream() {
		try {
			await zoomClient
				.getMediaStream()
				.detachVideo(userId, videoPlayerRef.current);
		} catch (e) {
			console.log('error detaching video stream', e);
		}
	}

	return (
		<div>
			<video-player class={`${style.video} video`} ref={videoPlayerRef} />
		</div>
	);
};

```

To reproduce this I create a `<ParticipantList />` and pass it a prop with a list of identities that are in the zoom room. That list will create a `<Participant />` for each identity which in turn will create a `<Track />` for each participant. In this Track component I use the `attachVideo` method, passing it the ref to the `<video-player>` element.

Below is a screenshot of what happens with one remote participant in the zoom room.

 ![DOM Screenshot](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/3/f/3fc1772854257944dc1dcf3d7d35065d657429aa.png)

---

<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:** [April 9, 2024, 2:52am UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/6 "2024-04-09T02:52:39Z")

</div>

Hey @tylertyler

Yes, indeed, our underlying implementation renders video using canvas. However, you can still use the `video-player` element for CSS styling purposes.

May I understand if you are looking to implement a masking feature?

I’m glad to hear that you’ve explored our mask feature. In the Video SDK Web, the masking functionality is only applicable to self-view video. This means that the mask is applied to the captured video stream before sending it to remote participants. Therefore, the received video stream on the remote end is already processed.

> I want to mask the video inside of a circle or rectangle

My recommendation would be to create a `div` element at the same level as the `video-player`, overlaying it. Then, you can achieve the masking functionality by modifying the properties of this `div` element, such as border, background, etc.

I hope this helps. If you have any further questions, please feel free to reach out to me.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![tylertyler](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tylertyler/32/58198_2.png) [@tylertyler](https://devforum.zoom.us/u/tylertyler)\
**Post date:** [April 9, 2024, 4:16pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/7 "2024-04-09T16:16:28Z")

</div>

I don’t think that’s necessarily true.

Here I wrapped the `<video-player>` in a div that has a set height and width - that works - but the displayed video does not respect the `overflow: hidden` property. You can see this container div has a border-radius of 50% (that is seen in the display) but the video is displayed outside the boundaries of this div where if what you said is true then I would expect the video to not be overflowing from the div.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/8/5/8556ea27efccd1b73ec511fd429ab4c821f7475a.jpeg)

---

<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:** [April 10, 2024, 6:45am UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/8 "2024-04-10T06:45:06Z")

</div>

Hey @tylertyler

I understand your point.

In reality, the video is rendered on the underlying canvas, and the `video-player` element serves primarily to assist in positioning the video coordinates. Consequently, videos are rendered in a square manner and cannot have rounded corners

This limitation stems from the current implementation. If employing the method I suggested earlier can resolve your issue in certain scenarios, then that would be an optimal solution.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![rg11389](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rg11389/32/58588_2.png) [@rg11389](https://devforum.zoom.us/u/rg11389)\
**Post date:** [April 12, 2024, 5:01pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/9 "2024-04-12T17:01:57Z")

</div>

This unfortunately won’t work to mask and overlay it on top of other content. Setting border and background would not mask the content, it would just overlay something over top of the video right?

---

<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:** [April 15, 2024, 2:14am UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/10 "2024-04-15T02:14:12Z")

</div>

Hey @rg11389

Yes. It simply overlays the video with additional elements.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![tylertyler](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tylertyler/32/58198_2.png) [@tylertyler](https://devforum.zoom.us/u/tylertyler)\
**Post date:** [April 29, 2024, 6:05pm UTC](https://devforum.zoom.us/t/possible-to-put-video-in-video-element-instead-of-canvas/107465/11 "2024-04-29T18:05:43Z")

</div>

Okay thank you @vic.yang for the information.

It sounds like at this point the Video SDK is not fully customizable for any UI needs and we will wait on updated versions hoping these things get added
