Closed nuthinking closed 8 months ago
Currently looking for an webm-demuxer....
A webm-demuxer
would be the cleanest solution, but this should still be somewhat possible even without FFmpeg. I'd spawn a hidden <video>
element, and then play that back. Then you can call captureStream, and then create a MediaStreamTrackProcessor:
new MediaStreamTrackProcessor({ track: videoTrack });
Then, similarly to how I do in my demo, you'll get individual VideoFrame
instances out! Which is great, because those hold unencoded video data which you can then simply reencode as usual and pipe into mp4-muxer
. You'll need to make sure to iron out the details to make sure you don't miss any frames in the input video, and you may need to have some custom timestamp logic, but this should still give you good results! FFmpeg should be the last resort :)
So, no way to use MediaStreamTrackProcessor
directly with a MediaRecorder
? The playback capture is way too hackish :)
Oh yeah wait I read over that. Why don't you record directly into mp4? Or simply skip MediaRecorder altogether?
Yeah, if the recording performances of a canvas via WebCodecs
are comparable to the ones of MediaRecorder
. That would make a lot of sense. I will try!
What are you recording? Just a canvas, right?
Yes, only thing I had to handle was that the canvas renders at much higher fps than the video I want to export. Thanks for the idea!
I record videos in WebM using
MediaRecorder
. I wonder if, perhaps with the combination ofVideoDecoder
, it would be possible to re-encode them into mp4 file without having to use ffmpeg for the conversion. 🤔