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

Compatibility issues #52

Closed erwanvivien closed 4 months ago

erwanvivien commented 4 months ago

Hey, huge fan of this library! 💜

I've recently change from using minimp4 to use this muxer! It works like a charm for most players but I seem to have lost some compatibility:

Repros

For colorful repros [download new](https://github.com/Vanilagy/mp4-muxer/assets/44021072/9189fe09-07ac-4dc5-bc2a-d52fa5c8c9b0). https://github.com/Vanilagy/mp4-muxer/assets/44021072/9189fe09-07ac-4dc5-bc2a-d52fa5c8c9b0 [download old](https://github.com/Vanilagy/mp4-muxer/assets/44021072/bf85be52-98a1-4fcd-b2a4-841e7de67912). https://github.com/Vanilagy/mp4-muxer/assets/44021072/bf85be52-98a1-4fcd-b2a4-841e7de67912
For minimal repros [download new](https://github.com/Vanilagy/mp4-muxer/assets/44021072/936bfd70-e43f-4244-824f-bd6d019531af). https://github.com/Vanilagy/mp4-muxer/assets/44021072/936bfd70-e43f-4244-824f-bd6d019531af [download old](https://github.com/Vanilagy/mp4-muxer/assets/44021072/5a6e7044-6e69-483b-87d6-f5e947f52457). https://github.com/Vanilagy/mp4-muxer/assets/44021072/5a6e7044-6e69-483b-87d6-f5e947f52457

Errors

Here is a screenshot of an error message from PPT:

image

This seems to have been fixed by installing K-Lite_Codec_Pack_1835_Standard

Here is the diplayed embedded version in Slack

Screenshot 2024-06-12 at 11 05 49

Small investigation

From the MP4Box filereader page I could found small differences in the exported videos (I used the minimal ones)

New one

Screenshot 2024-06-12 at 11 12 07

Old one

Screenshot 2024-06-12 at 11 12 46

Thanks for your time & insights

I'm happy to help fix the bug if you can provide guidance 👍

erwanvivien commented 4 months ago

Updated: This is not urgent at all and seems to be related to fastStart: "fragmented"

When I change to false / "in-memory" it seems to be playing well in Slack at least!

Minimal repros (false / in-memory) [donwload `fastStart: false`](https://github.com/Vanilagy/mp4-muxer/assets/44021072/638fcb9b-3a08-4861-b8fa-72ad07858661). https://github.com/Vanilagy/mp4-muxer/assets/44021072/638fcb9b-3a08-4861-b8fa-72ad07858661 [donwload `fastStart: "in-memory"`](https://github.com/Vanilagy/mp4-muxer/assets/44021072/3d8b3586-e309-40b4-83f5-9bce55075d87). https://github.com/Vanilagy/mp4-muxer/assets/44021072/3d8b3586-e309-40b4-83f5-9bce55075d87
MP4Box filereader analysis ### `fastStart: false` Screenshot 2024-06-12 at 11 44 58 ### `fastStart: "in-memory"` Screenshot 2024-06-12 at 11 44 46
Vanilagy commented 4 months ago

It could be that PowerPoint doesn't like fragmented MP4, perhaps? We should verify that it's that and not this library having an error in its fMP4 file structure. Try piping your MP4 file (the one that isn't fragmented) through this:

ffmpeg -i input.mp4 -c copy -f mp4 -movflags +frag_keyframe+empty_moov+default_base_moof output.fmp4

This makes it fragmented. See if you can pop that into PowerPoint.

erwanvivien commented 4 months ago

Thanks for the FFmpeg command!

Indeed this one does not displays on Slack for example. So that's great, no bugs really in the code 🎉

My only question for my knowledge then is why in the fragmented version, the headers seems broken? I know fragmented splits the header in chuncks, is it MP4Box that does not read them or it's expected to show duration 0 / or filesize NaN?

Thanks for the prompt replies 🙏

Vanilagy commented 4 months ago

The header is not broken, it's just that not all metadata is contained in the header anymore. In the header in a fragmented file, a lot of the data is left blank (like duration, sample data), and it's completed using the moof boxes spread throughout the file. That's why it's called fragmented!

erwanvivien commented 4 months ago

Yep that was my understand with bad wording haha, thanks for the clarifications on the blank spaces 🙏 Much appreciated