audiocogs / mp3.js

A JavaScript MP3 decoder for Aurora.js
http://audiocogs.org/codecs/mp3
263 stars 45 forks source link

VBR files #9

Open nazar-pc opened 10 years ago

nazar-pc commented 10 years ago

I've reported here: https://github.com/audiocogs/aurora.js/issues/83 But it turns out that VBR mp3 files are not supported. libmad on which mp3.js is based is very old and doesn't support modern files. I was browsing few hours, but there is nothing here I can do in order to fix this (i've tried to play with emscripten, but no luck with some mp3 decoders. Is there any chance to have alternative decoder, that will support all modern mp3 files?

devongovett commented 10 years ago

Have you confirmed that libmad cannot decode the file you linked to in https://github.com/audiocogs/aurora.js/issues/83? I want to be sure the issue is VBR, because I thought I had written code for that a while ago.

nazar-pc commented 10 years ago

I didn't found easy way to try libmad, all maintained software moved to another decoders. Actually, that file in audiocogs/aurora.js#83 has CBR, VBR support I've tested on: https://dl.dropboxusercontent.com/u/62195352/Taylor%20Swift%20-%20Untouchable%20%28Luna%20Halo%29.mp3

Generally I have such output in console while debugging Firefox OS app:

Error: Invalid sampling frequency ac.mp3.js:495
Error: Invalid bitrate ac.mp3.js:484
Error: Invalid layer ac.mp3.js:475
Error: Invalid bitrate ac.mp3.js:484
Error: Invalid layer ac.mp3.js:475
Error: Invalid bitrate ac.mp3.js:484
Error: Invalid sampling frequency ac.mp3.js:495
Error: Invalid bitrate ac.mp3.js:484
UnderflowError: 
Error: Invalid sampling frequency ac.mp3.js:495
Error: Invalid bitrate ac.mp3.js:484
Error: Invalid layer ac.mp3.js:475
UnderflowError: 
Error: Invalid bitrate ac.mp3.js:484
Error: Invalid sampling frequency ac.mp3.js:495
Error: Invalid layer ac.mp3.js:475

More than half of files play nicely, but others fails with various errors. I've tried to patch mp3.js substituting known CBR and sampling frequency (obtained from other software), but anyway I didn't get anything other than UnderflowError

devongovett commented 10 years ago

There's a command line player called madplay that you can install on most OSes using a package manager (e.g. homebrew on mac, apt-get on linux).

I know I have VBR files that work with mp3.js, I just tested one, so I'm not sure what's wrong with this file. It seems more than just the bitrate is corrupted in some of the frames too, given the Invalid sampling frequency errors and Invalid layer errors there too. Perhaps other mp3 decoders just skip the frame instead of throwing an error?

nazar-pc commented 10 years ago

I've tried madplay, it just fails (Ubuntu 14.10 x64), probably supposed to work with older sound sub-systems:

nazar-pc@nazar-pc:~$ madplay '/media/Data/ABGT075.mp3' 
MPEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
audio: No such file or directory

I've tried to comment out errors throwing, it doesn't work either. No success with that files.