abema / go-mp4

Go library for reading and writing MP4 file
https://dev.to/sunfishshogi/go-mp4-golang-library-and-cli-tool-for-mp4-52o1
MIT License
466 stars 30 forks source link

Wrong SampleRate calculation for mp4a box #137

Closed merlor closed 1 year ago

merlor commented 1 year ago

Hello, I've tried to launch the command mp4tool dump <file>

The file (linked below) represent the init file of an audio stream that I'm using in my projects; the command works fine but the value "SampleRate" calculated for the mp4a seems not correct.

With other tools the sample rate is 44100 (ac 44) but with mp4tool the value is 2890137600 (curiously ac 44 00 00) Am i doing something wrong? Is the file "not correct"? Do I have to use a different command?

P.S. I'm quite a beginner in MP4 spec so, probably I'm missing something; thank you in advance for any response

The file that I'm using for test init.zip

sunfish-shogi commented 1 year ago

@merlor Thank you for contacting.

SampleRate of mp4a (AudioSampleEntry) is 32bit integer which indicates a 2^16 times of sampling rate. 2890137600 = 44100 * 2^16

The current version of mp4tool-dump command displays raw value of SampleRate without formatting. It is not wrong, but is not easy to read for human. I'll update this tool to displays its value as fixed-point number format.