minimp4.rs icon indicating copy to clipboard operation
minimp4.rs copied to clipboard

support mux more audio formats

Open gogojames opened this issue 2 years ago • 7 comments

` let audio_data=Vec::from(include_bytes!("goodaf.mp3") as &[u8]); let pcm = vec!(0);

mp4muxer.init_audio(32, 24000, 1);

mp4muxer.write_video_with_audio(&audio_data, 60, &pcm);

`

gogojames avatar Sep 17 '23 06:09 gogojames

At present, only pcm is supported to be encapsulated into mp4, and the internal implementation will encode pcm into aac: https://github.com/darkskygit/minimp4.rs/blob/34271320d8809a40f839592efa226cc7795b91b2/packages/minimp4/src/writer.rs#L119-L122

darkskygit avatar Sep 17 '23 06:09 darkskygit

How to set codec:MP3(MPEG audio layer 3)

gogojames avatar Sep 17 '23 08:09 gogojames

There is no parsing of mp3 in the current implementation.

In mp4, the audio data is stored according to simple (frame), so you need to parse and disassemble the mp3 into a series of frames, and then set it to the corresponding mdat in order.

The following code is to set each frame of aac to the corresponding position:

https://github.com/darkskygit/minimp4.rs/blob/34271320d8809a40f839592efa226cc7795b91b2/packages/minimp4/src/writer.rs#L136-L143

darkskygit avatar Sep 17 '23 09:09 darkskygit

Oh, there is a harsh sound when playing, what should I do?

gogojames avatar Sep 17 '23 09:09 gogojames

are you using pcm? current pcm to aac implemention may not fully correctly

so previously, i was considering refactoring the encoding feature and splitting it into a separate package, but i haven't had time to refactor it recently.

darkskygit avatar Sep 17 '23 11:09 darkskygit

Is it difficult to do?

gogojames avatar Sep 17 '23 11:09 gogojames

just because i don't have free time recently

darkskygit avatar Sep 17 '23 12:09 darkskygit