Sample Rate Conversion (Lame)

Discuss anything related to portable freeware here.
Post Reply
Message
Author
User avatar
juverax
Posts: 368
Joined: Mon Jun 11, 2018 5:19 am

Sample Rate Conversion (Lame)

#1 Post by juverax »

Sample Rate Conversion of MP3z with Lame Enc used as a Command Line in a Batch File:
Simple, the fastest a sample rate conversion can be, highly reusable, minimal resources use :)

So ... here we are ... it is all about the batch conversion of MP3 Sample Rates.

I know of at least two freeware applications with GUI that can convert the sample rates of MP3 files in batch mode:
LEAPIC ( https://www.leapic.com/free-audio-converter.htm )
LameXP ( https://www.portablefreeware.com/index.php?id=2094 )
For me these applications work flawlessly BUT, they require that you learn how to navigate the interface .... which may be time consuming.

My personal usability metrics : The number of clicks it takes to get the job done :P
Therefore for this particular task I prefer LAME ENC used as a command line executable in a batch file.

It is HIGHLY REUSABLE, all you have to do is to move around your MP3 files (source files and converted files).

Get Lame: https://www.rarewares.org/mp3-lame-bundle.php
( https://www.rarewares.org/files/mp3/lame3.100.1-x64.zip )

The only file you need here is "lame.exe" (VirusTotal Score= Clean, but feel free to retest)

The purpose of the following "How-To" is to show how to use "Lame Encoder" as a CLI (actually embedded in a batch file) to convert the sample rates of MP3 files before these files can be burnt with an Audio-CD burner (application) that requires imperatively a sample rate of 44100, such as Burrrn ( https://www.portablefreeware.com/index.php?id=684 ) .

Currently I am using Burrrn because AFAIK this is the only free and modern application that can burn CD-Text and leave the Audio-CD open for a second (data) session, that can be burnt at a later time with CDBurnerXP ( https://www.portablefreeware.com/index.php?id=2992 ) that has the ability to import previous sessions.

The MP3 files extracted from youtube videos typically have a SAMPLE RATE of 48000 (AFAIK).

Another bit of information that we need is the BIT RATE, that we can determine using mediainfo ( https://www.portablefreeware.com/index.php?id=884 ), just look for the average bit rate.
If these MP3 files are audio files extracted from youtube videos, the average bit rate is in the range 157-159 (???)
In the following example we use a bit rate of 157.
In my opinion, I may be wrong, I believe it is a waste of resources to convert to a higher bit rate, because that won't improve the quality of the final audio file, and quality was not there in the first place.
The higher the bit rate, the bigger the file size.

Create a folder that you name what you want ...for instance ... samplerateconv
In the folder samplerateconv

1 - Place in the folder the MP3 files for which you want to change the sample rate to 44100

2 - Place in the folder lame.exe (make sure to use a recent version in order to preserve the MP3 tags)

3 - Create a text file (name it what you want ... for instance lameconv.txt) and insert the two following lines (exactly like that

md 44100
for %%i in (*.mp3) do lame -b 157 -q 0 --resample 44.1 "%%i" ".\44100\%%i"

4 - save and exit

5 - rename lameconv.txt lameconv.bat


NOTE: There are several switches you can use with lame.

You are now ready to convert your MP3s:
- Double click on lameconv.bat
- Wait until the end of the conversion
- Now all the converted MP3 files are in the 44100 folder
- They are now ready to be written to an Audio-CD, the MP3 Tags are preserved and can be burnt as CD-Text

NOTE 1: The two lines of code above can only be run from a batch file, NOT from the command line.

NOTE 2: I read somewhere that CDRTFE ( https://www.portablefreeware.com/index.php?id=694 ) can as well burn MP3s to Audio-CD with CD-Text and leave the Audio-CD open for a second data session. Apparently this is not a straightforward process but rather a "workaround" the "apparent but not real" limitations of CDRTFE in this respect. :x
CDRTFE does not seem to require a 44100 sample rate . . . It seems to be able to convert the sample rate behind the scene.
Maybe later I can post something about how to use CDRTFE for multi-sessions CDz.

Enjoy! :D :D :D

toitoy
Posts: 12
Joined: Tue Sep 02, 2008 10:17 am

Re: Sample Rate Conversion (Lame)

#2 Post by toitoy »

I strongly suggest you against this kind of conversions. MP3 is a lossy format you already lost some quality making it an MP3 with such conversions you will loose some more audio quality. Sample rate conversion is only justified when converting from lossless formats like 'wav' or 'flac'.
It's better to do this kind audio operations with high quality player like Foobar, if you set up everything right it will take you 1-2 mouse clicks. Foobar can even make an audio CD for you

User avatar
Midas
Posts: 6727
Joined: Mon Dec 07, 2009 7:09 am
Location: Sol3

Re: Sample Rate Conversion (Lame)

#3 Post by Midas »

What toitoy said -- unless you need to play in a device that can only play MP3, that is -- each conversion you're performing (M4A => MP3 => WAV) will in fact degrade your audio quality...

Better yet, Yt native M4A/Opus audio formats (which are already losssy, BTW, although the former could also be non-lossy, apparently, in a different context) are technically more up-to-date and will yield superior quality with lower bitrates. If you really need to go back to WAV for CD burning, better do it directly (M4A => WAV).

User avatar
juverax
Posts: 368
Joined: Mon Jun 11, 2018 5:19 am

Re: Sample Rate Conversion (Lame)

#4 Post by juverax »

@toitoy, @midas ... Thank you for the suggestions
Currently I am not too much concerned with the quality of these audio files (though I should) because I am processing vinyl rips of very old records not in their prime condition.
Sometimes the original vinyl track is damaged beyond hope of recovery, and I try to replace it with a youtube video if it exists (extract the audio , and adjust the sample rate).
Also, I want to preserve as much information as possible: embed the original track name in the rip file (--> tags), in the final Audio-CD track (--> CD-Text) and the art work (scans of the sleeve of the original LP disc) and any relevant information in the final CD (--> multi-session CD).
But definitely, I should review each step of the archival processes and aim at a higher quality.
It is something that I am doing occasionally for family members who want to "downsize".
When first I offered to archive/digitize the vinyl discs, I had no idea it would be time consuming.
I took up the challenge as an opportunity of learning "something new"!

Thanks to all for the help.

Post Reply