Vanilagy / mp4-muxer

MP4 multiplexer in pure TypeScript with support for WebCodecs API, video & audio.
https://vanilagy.github.io/mp4-muxer/demo
MIT License
419 stars 32 forks source link

Dynamic browser support #30

Closed AmitMY closed 9 months ago

AmitMY commented 9 months ago

Similar to https://github.com/Vanilagy/webm-muxer/issues/32 I use both webm-muxer and mp4-muxer with a manual check for browser version, which had proved unreliable. Ideally, I would like to start with the webm-muxer, try to make it playable (remove alpha, change codec, etc), but if the container is not supported at all, revert to mp4-muxer, and then do the same (remove alpha, change codec, etc).

This requires both libraries to have isPlayable() and makePlayable() methods

Vanilagy commented 9 months ago

Playback compatibility is a complex issue outside the scope of this library, which is merely a muxer. Since it also depends on the exact codecs at play, which the muxer has no idea about, it won't have enough information to accurately determine compatibility. Of course, this muxer tries its best to generate well-formed videos that are played back by as many video players as possible, so any bug reports about compatibility problems are still welcome. However, some browsers simply don't like WebM that much.

Your best bet would be to keep experimenting to find a good heuristic for compatibility. I say if you care about maximizing compatibility, you should always use MP4. If you want to utilize the higher quality of WebM, one idea would be to make the video type explicitly selectable by your users, or do use WebM when on Chrome or Firefox. You could also ship a tiny WebM video pre-created by webm-muxer which you then try to play in a <video> element. If it errors, you choose MP4, otherwise you keep WebM.