Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Video Uploading with WebCodecs sample #247

Merged
merged 4 commits into from
Apr 14, 2023

Conversation

beaufortfrancois
Copy link
Collaborator

@beaufortfrancois beaufortfrancois commented Apr 7, 2023

This PR adds a sample "Video Uploading with WebCodecs", similar to "Video Uploading", so that web developers can play with importExternalTexture() and VideoFrame from Web Codecs API.

image

src/sample/videoUploadingWebCodecs/main.ts Outdated Show resolved Hide resolved
src/types.d.ts Outdated Show resolved Hide resolved
@beaufortfrancois
Copy link
Collaborator Author

@kainino0x Please have another look. This PR is now ready for review.

src/sample/videoUploadingWebCodecs/main.ts Outdated Show resolved Hide resolved
src/sample/videoUploadingWebCodecs/main.ts Show resolved Hide resolved
src/sample/videoUploadingWebCodecs/main.ts Show resolved Hide resolved
minFilter: 'linear',
});

function getVideoFrameFromVideoElement(video) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know this API at all so can't really review this. Seem reasonable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem rather complex given that VideoFrame has a constructor that takes an HTMLVideoElement. But maybe this is necessary. It would be nice to document why it's done this way, because it's in a sample that people will reference and copy from. @shaoboyan could you help with this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kainino0x (OOO last Friday). Sry for late reply. Since we use pre-recorded video file as the input for VideoFrame, we need to use HTMLVideoElement to play it and call captureStream to get the VideoFrame. I considered constructing video frame in another way by using canvas and captureStream to canvas but it seems in that way we cannot cover multiple color space.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to remove the getVideoFrameFromVideoElement function and simply use const videoFrame = new VideoFrame(video); for this sample if it helps.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works for this sample I think we should.

@shaoboyan the color space issue is just due to the canvas, right? What about the new VideoFrame(video) codepath, does that work?

Copy link
Contributor

@shaoboyan shaoboyan Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shaoboyan the color space issue is just due to the canvas, right?

Yes, due to canvas constraint color space.

What about the new VideoFrame(video) codepath, does that work?

That would be ideal!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! See #251

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants