[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUDITORY] Converting audio file from WAV to MP3 changes file duration. Why?



Dear Neeks,

Your wav audio files can have an arbitrary lenght, depending on the duration of the audio sample. The mp3 audio file however, is a sequence of frames with a certain length in bytes, and thus also in duration. After going from wav to mp3 and back, you will see that the the duration of your audio sample has changed. I guess there will be some zero padding or small conversion artifacts before and after the 'real' audio.

This may have been designed this way to prevent the introduction of audible clicks at the beginning and at the end when playing an mp3 file.

If you need the duration of your audio files to be maintained, mp3 may not be what you want.

Best wishes,
Günter


On 15 Nov 2017, at 08:02, Neeraj Sharma <neerajww@xxxxxxxxx> wrote:

Dear Members,

An audio file in WAV can be converted to MP3 using following two utilities in unix terminal (both work, and there may be many more also):

$ ffmpeg -i <input.wav> -codec:a libmp3lame -b:a 320k <output.mp3> </dev/null
$ lame -q0 -b128 <input.wav> <output.wav>

But the issue is that the duration of <output.mp3> is more than duration of <input.wav>. This is true with other utilities which I have tried, like sox. Can anyone give insight on:

a. why the duration is increasing? In the attached image below, the duration variation is plotted for 410 sound files. The increase in duration appears to be WAV file dependent (although it is within 140ms in this case)

b. is there option in the above utilities which can reduce this difference in duration?  I haven't been able to figure this out.

Similar issue has been reported by few others also.
Example: https://www.sweetwater.com/forums/showthread.php?42631

Best regards,
Neeks


<duration_var_wav_mp3.png>

ing. Günter Windau | Technical Support Group | Dept. Biophysics Donders Institute for Brain, Cognition and Behaviour Radboud University Nijmegen Heyendaalseweg 135, NL-6525AJ Nijmegen room 00.817 | E: G.Windau@xxxxxxxxxxxxx | T: +31 24 3613356 W: http://www.mbfys.ru.nl/~gunter