0
$\begingroup$

Do you have any idea on why the Calculation 1 below doesn't match?

Reference:

Audio buffers: frames, samples and channels

VLC - Media Information:
   num channels: 2 (stereo)
    sample rate: 44100 Hz
bits per sample: 32 => bytes per sample: 4
        bitrate: 192 kb/s
       duration: 7 mins, 23 secs => 443 secs

Windows - File Properties:
           size: 10,642,422 bytes => 10393 KB

Calculation 1 (without using bitrate) (using rounded values for simplicity)

1 second: 44100 samples => 44100 * 4 = 176400 bytes => 172 KB (looks a lot for just 1 sec)
This way: 443 secs => 443 * 172 KB = 76196 = 74 MB, but the file just 10 MB (!!! Contradiction !!!)

Calculation 2 (using bitrate)

 bitrate: 192 kb/s => 24 KB/s
1 second: 24KB => 443 seconds: 443 * 24 KB = 10632 KB = 10393 KB (like above) + [some metadata] (!!! Match !!!)

Thanks!

$\endgroup$
2
$\begingroup$

Because the file is compressed. The sample rate and bits per sample are parameters of playback after decompression. The file size is for the compressed format, the amount of data that needs to be downloaded, not the amount of data that reaches the digital-to-analog converter.

$\endgroup$
4
  • $\begingroup$ thanks @SF for the clarification. By the way, maybe you can help me to clarify this problem I'm having here: stackoverflow.com/questions/52513425 $\endgroup$
    – davidesp
    Sep 26 '18 at 16:50
  • $\begingroup$ @davidesp: You won't get that by trying to calculate the start/end byte of the compressed file. The compression, following psychoacoustic model, compresses some parts of the audio stronger, some weaker, so the recording timing is very loosely bound to file position. Never mind you need at least a couple blocks back because the compression strongly depends on modifying sound that is already being played; you can't start from scratch at any random point. There's a whole abstraction layer of mp3 index where recording times are mapped to byte layout. $\endgroup$
    – SF.
    Sep 26 '18 at 17:39
  • $\begingroup$ thanks @SF. So, do I have any option on my post linked on the url above (StackOverflow)? $\endgroup$
    – davidesp
    Sep 26 '18 at 17:52
  • $\begingroup$ @davidesp: I don't know what tools Javascript and the Web Media API provide. The low-level way about it would be to download the header/index, decode it, determine the file position of the correct fragment, download blocks containing it, decode them, advance within the first decoded block to start of audio you want, and play until the position of end of audio within the last block. Definitely not a thing you want to do on raw binary through javascript though. $\endgroup$
    – SF.
    Sep 26 '18 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.