njh / twolame

MPEG Audio Layer 2 (MP2) encoder
http://www.twolame.org/
GNU Lesser General Public License v2.1
59 stars 34 forks source link

twolame outputs a file with wrong audio duration #100

Open ousia opened 3 years ago

ousia commented 3 years ago

@njh,

converting the WAVE version from https://soundbible.com/2008-0-9-Male-Vocalized.html (direct download) using twolame, the resulting MP3 file gives wrong audio duration.

Flash animation (remove .txt extension to drag and drop at https://ruffle.rs/demo/).

Both lame and twolame are invoked using -m m -b 32.

lame outputs has a duration of 12278ms and twolame has a duration of 6113ms.

Of course, the official Flash player gives the same numbers.

I wonder whether it would be possible to fix twolame, so that audio duration info isn’t wrong.

Many thanks for your help and your excellent work.

eblanca commented 2 years ago

You didn't mention which twolame version is producing this wrong file. My build of latest git source (commit 90b694b6125dbe23a346bd5607a7fb63ad2785dc) is creating a file which is 12.20 s long:

$ soxi 0-9_Male_Vocalized-Mike_Koenig-1919515312.mp2 

Input File     : '0-9_Male_Vocalized-Mike_Koenig-1919515312.mp2'
Channels       : 1
Sample Rate    : 44100
Precision      : 16-bit
Duration       : 00:00:12.20 = 537984 samples = 914.939 CDDA sectors
File Size      : 48.6k
Bit Rate       : 31.8k
Sample Encoding: MPEG audio (layer I, II or III)

Please, make sure you're running the latest version of twolame and encode that file again.

ousia commented 2 years ago

Many thanks for your reply, @eblanca.

Sorry, latest stable release is version 0.4.0.

I’m on Linux now and Fedora ships version 0.3.13 of twolame.

But as far as I can remember, this was also an issue with version 0.4.0 in Windows (not easy for me to check it now).

In any case, I get the a very similar output to yours with version 0.3.13 for the MP3 file:

$ soxi Desktop/0-9_Male_Vocalized-Mike_Koenig-1919515312.mp3 

Input File     : 'Desktop/0-9_Male_Vocalized-Mike_Koenig-1919515312.mp3'
Channels       : 2
Sample Rate    : 44100
Precision      : 16-bit
Duration       : 00:00:12.20 = 537976 samples = 914.925 CDDA sectors
File Size      : 292k
Bit Rate       : 192k
Sample Encoding: MPEG audio (layer I, II or III)

And for the WAVE file:

$ soxi Desktop/0-9_Male_Vocalized-Mike_Koenig-1919515312.wav 

Input File     : 'Desktop/0-9_Male_Vocalized-Mike_Koenig-1919515312.wav'
Channels       : 2
Sample Rate    : 44100
Precision      : 16-bit
Duration       : 00:00:12.20 = 537936 samples = 914.857 CDDA sectors
File Size      : 2.15M
Bit Rate       : 1.41M
Sample Encoding: 16-bit Signed Integer PCM

Flash Player reports a sound duration of 13 ms for the MP3 version and 12173 ms for the WAV file.

If I use twolame -m m -b 32, Flash Player reports a sound duration of 6100 ms, although I get:

$ soxi Desktop/0-9_Male_Vocalized-Mike_Koenig-1919515312.mp3 

Input File     : 'Desktop/0-9_Male_Vocalized-Mike_Koenig-1919515312.mp3'
Channels       : 1
Sample Rate    : 44100
Precision      : 16-bit
Duration       : 00:00:12.20 = 537976 samples = 914.925 CDDA sectors
File Size      : 48.6k
Bit Rate       : 31.9k

Using lame -m m -b 32, Flash Player reports the right sound duration (12251 ms) and I get:

$ soxi 0-9_Male_Vocalized-Mike_Koenig-1919515312.mp3 
Input File     : '0-9_Male_Vocalized-Mike_Koenig-1919515312.mp3'
Channels       : 1
Sample Rate    : 22050
Precision      : 16-bit
Duration       : 00:00:12.25 = 270157 samples ~ 918.901 CDDA sectors
File Size      : 49.0k
Bit Rate       : 32.0k
Sample Encoding: MPEG audio (layer I, II or III)

I must admit this is all Greek to me, it seems that Flash Player has problems to extract sound duration in MP3 files generated by twolame.