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 captureStream() method #1698

Open
piranna opened this issue Nov 7, 2020 · 6 comments
Open

Add captureStream() method #1698

piranna opened this issue Nov 7, 2020 · 6 comments
Labels

Comments

@piranna
Copy link
Contributor

piranna commented Nov 7, 2020

Add missing captureStream Canvas method. It returns a MediaStream object, where on each canvas change a new frame is being added with the actual canvas contest. This is similar to using node-webrtc RTCVideoSource class and calling to its onFrame() method, so probably some code could be reused between both projects. A polyfill can also be created to add that feature, but it would need first to have merged my changes to notify paint operations.

@BrandonQDixon
Copy link

I see this issue is 2 years old almost, but this repository is still being maintained. Would it be possible to get that previous PR merged as described in the issue so we can move forward on implementing the missing "captureStream" functionality? Alternatively, is there a different way we can get a MediaStream object (or otherwise something which we can use to serve a video stream via express js?)

@LeviPesin
Copy link

LeviPesin commented Oct 24, 2022

As a workaround the following can be used instead:

const i420Frame = {width, height, data: new Uint8ClampedArray(1.5 * width * height)};
const imagesSource = new WebRTC.nonstandard.RTCVideoSource();
const imagesTrack = imagesSource.createTrack();
const mediaStream = new WebRTC.MediaStream([imagesTrack]);

// on each frame
const frame = context.getImageData(0, 0, width, height);
WebRTC.nonstandard.rgbaToI420(frame, i420Frame);
imagesSource.onFrame(i420Frame);

@princefishthrower
Copy link

@LeviPesin - can you elaborate? That code snippet doesn't include the canvas object at all.

@LeviPesin
Copy link

frame is an image data that should be added to track, I've added a line getting it from the canvas.

@LIMPIX31
Copy link

LIMPIX31 commented Sep 7, 2023

I'm surprised we still don't have it

@tempranova
Copy link

Another vote to get this working!

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

No branches or pull requests

7 participants