Open Kaiido opened 4 years ago
@Kaiido I apologize for this delayed response. Yes, I agree with you that transcoding is a very slow process.
I am waiting for more feedback here but at the least I think adding an AbortController to finalize() is a good idea irrespective of transcoding.
There seems to be some strong assumptions in this proposal that video editing is just a matter of moving some bytes like we can already do with
Blob.slice()
.Some media formats may indeed allow trimming or concatenation of streams quite easily by moving only some atoms and updating the metadata, but first, this is not true for all media formats, and second, reencoding is always a very slow operation.
For instance reencoding a vp8 video to vp9 through ffmpeg is done at around 3.5FPS on my 4 cores machine, and even reencoding to h-264 which has a lower compression rate only reaches an average of 25FPS not sure how it would work on a low end mobile phone, I guess it would either fail from battery, or from memory before anything is done.
All in all, while I would also have loved to be able to do such reencoding, I don't think the
mimeType
parameter ofMediaBlobOperation.finalize()
is a great idea. I believe we should avoid reencoding as much as possible.And if you really want to go this route, then I think it should be refactored in a way the script
ondatavailable
? That may require a MediaBlobFinalizer interface. Or it could return a ReadableStream? (if only we could finally make something useful of it like upload or saving on disk...)