minimp4.rs
minimp4.rs copied to clipboard
support mux more audio formats
` 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);
`
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
How to set codec:MP3(MPEG audio layer 3)
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
Oh, there is a harsh sound when playing, what should I do?
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.
Is it difficult to do?
just because i don't have free time recently