Closed yangfangfang1204 closed 1 year ago
This is relatively straightforward (make a buffer, copy, create a new VideoFrame
with matching metadata), but it's not a very efficient method for caching. It is the best option if you need your copies to be stored in system RAM, though.
If GPU RAM is not scarce (and your frames are hardware), I would recommend createImageBitmap()
since it can in most cases avoid doing readback. It will do conversion to RGB, but in most cases that is more efficient than readback.
The best method would be the proposed VideoFrame.copy()
API, see #436. I'm going to hold of producing a demo until I'm sure of what is happening with that API.
This is is exactly the same question I have: how to make copyTo() work. Copying the attributes of frame and passing them in options as in https://github.com/w3c/webcodecs/issues/501#issuecomment-1162284163 throws error...
is there a demo that how to use VideoFrame.copy()
, And What is the return value of the VideoFrame.copy()
? Is it a shared texture index or shared texture data?
There is no demo of copy()
because copy()
is not yet specified. It would return a new VideoFrame
.
Could use a sample, but copyTo
now has MDN documentation, let us know if that's insufficient.
How to cache decoded VideoFrames By CopyTo , is there demo?