Closed shenanigans closed 8 years ago
Thanks! I'll look soon.
@Ivshti, do you use wcjs-renderer
and fallbackRenderer
option? If yes, this patch could break your code.
@RSATom I don't use wcjs-renderer at all because I implemented it before that.
You have to be careful with preserveDrawingBuffer - it's a big performance penalty
Passing a Boolean for fallbackRenderer
is detected and handled so it should be safe for users of that option as long as they aren't abusing truthy values. I'm comfortable with the performance penalty of preserveDrawingBuffer
when generating thumbnails as I only let frameReady
go off twice. File loading and seeking are the real costs there. I don't want to put up with it anywhere else, hence bothering to make it optional.
@shenanigans I agree, and you make a good point. What I'm doing personally is creating a new canvas for snapshotting, then using the last value from wcjs onFrameReady and rendering in, by re-using some of the renderer code. It's a bit extra work, but it uses preserveDrawingBuffer only when completely needed - therefore eliminating any performance penalty.
Is it not possible create image from js array without using canvas?
Of course it is, but why write logic & implement image compression if canvas provides that for you?
I just think it could have some overhead.
I bet it would be faster than having V8 do your rendering logic and png/jpg compression, since
Doesn't matter though, I doubt there's a usecase where performance matters much for taking snapshots
If you want a PNG out your best performance option will probably involve a canvas at some point. I found it convenient to let canvas and wcjs-renderer
take care of certain crucial tasks, such as having a clue what I420 is. That frame conversion step is certainly going to be faster in webgl than a javascript loop, probably enough to make wrangling a canvas worth it. By the way, I've been reusing the same canvas instance forever without any problems.
Applied, thanks!
I've been generating thumbnails for video files with webchimera and needed to support the
preserveDrawingBuffer
option forgetContext
. This lets you work with the canvas' frame data using normal canvas methods.This pull request shouldn't break any code but adds the following invocation option: