-
Notifications
You must be signed in to change notification settings - Fork 101
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
How to get a callback when a frame is decompressed? #632
Comments
I think the simplest way is to hack OGVWrapperCodec.decodeFrame to wrap a custom callback. Something like this ought to do it on top of a stock ogv.js distribution, or you could modify the main code and rebuild it: // player._codec is an OGVWrapperCodec but this class is not exposed globally
let proto = Object.getPrototypeOf(player._codec);
proto._decodeFrameOrig = proto.decodeFrame;
proto.decodeFrame = function(callback) {
this._decodeFrameOrig((ok) => {
if (ok) {
let frame = this.frameBuffer;
// <- add custom processing
}
callback(ok);
}]);
} Note this will fire while decoding during seeking operations as well as when buffering up data for playback. Let me know if you have any trouble! |
Great, I've made this change on a basic javascript implementation in a basic HTML file, out of the ogv.js api:
I have a couple of questions:
Specifically, are there any best practices or potential pitfalls I should be aware of when implementing this directly in the HTML?
My ultimate goal is to use the video element as a texture in Babylon.js. Are there any examples or recommended approaches for integrating ogv.js with a web engine for this purpose? Thank you in advance! |
let canvas = player._canvas;
let frameRate = 30;
let stream = canvas.captureStream(frameRate);
let url = URL.createObjectURL(stream);
let video = ...; // your target <video> element
video.src = url;
video.muted = true; // so you can start the video-only stream programmatically
video.play(); Alternately, you might be able to use the canvas directly as a texture source, skipping the pipe into the video element. https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream |
I've made that directly into the html
But I'm not sure if it will introduce some performance penalties. "modifying directly do you mean in the ogv.js blob?" Maybe I could do that on the player and run makefile again. |
I need a per frame synchronization so HTMLVideoElement requestVideoFrameCallback is not enough and I need a signal that is triggered once the frame has been decoded.
Is there something like that on ogv.js? (I don't think so)
Is there any easy modification to make that? (Maybe with a tip I could do it and commit it back as a patch)
I really appreciate any help you can provide.
The text was updated successfully, but these errors were encountered: