WICG / video-editing

Other
65 stars 8 forks source link

Reencoding a full video is not a 3s operation. (about current finalize()) #7

Open Kaiido opened 4 years ago

Kaiido commented 4 years ago

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 of MediaBlobOperation.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

ykh015 commented 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.