mattdesl / mp4-h264

[project suspended] MP4 + H264 encoding for the browser with WASM
MIT License
223 stars 12 forks source link

Adding Audio #8

Open Luxapodular opened 3 years ago

Luxapodular commented 3 years ago

Thanks for putting together this Library @mattdesl! I'd like to see If I can add audio to mp4s generated with this library.

Has there been any work on this so far? If I'm able to help, I'd be happy to either through code or some type of monetary contribution to get this going!

mattdesl commented 3 years ago

Hey thanks! Muxing audio shouldn’t be too hard, as minimp4 supports AAC track (not sure if MP3 would work) so it’s a matter of just adding the C code. The difficult thing is encoding WAC to AAC, which probably shouldn’t be included in this module anyways (ie: this would only expose muxing and it’s up to end user to figure out encoding), but it’s worth highlighting how that might work:

There is an emscripten port of FDK encoder floating around and it might be good to make it work with this module, but the FDK license is not truly free open source so might not be ideal for most users.

Another solution would be to support WebCodecs (Chrome only), which I got working in this module for muxing video, so I imagine it wouldn’t be too hard to add in audio if the browser includes an AAC encoder (haven’t looked).

And yet another option is just to let the user supply an MP3 buffer (ie from a file input).

Luxapodular commented 3 years ago

Alright, cool. I'll take a look at these options and see what might work. I'm personally leading toward the user supplying an mp3/audio buffer, but agree that the encoding step should not be built in here.

edankwan commented 3 years ago

If I have the AAC file, how do I mux the track into the container?