Sign in to follow this  
Followers 0
Bert

MP3 file Resizer

7 posts in this topic

#1 ·  Posted (edited)

With some help from a few folks, here is my MP3 file Resizer. The idea behind this tool (well, need) was for the many audio books I listen to. When I would rip a CD, it would sample at 128Kbps. For my needs 32Kbps would do the trick fine. Size is my main driver, and since it is just an audio book, quality can be somewhat compromised to get the size down. Windows Media player would not let me set the bit rate to 32 Kbps so that is why the need for this tool is needed.

I compiled it with LAME.exe. LAME.exe is open source software that allows one to work with sound files. You can get more information on LAME here:

http://lame.sourceforge.net/

Another tool I use is MergeMP3. This tool is a no fuss, no muss app that does one thing well - it lets you merge mp3 files.

http://www.shchuka.com/software/mergemp3/index.html

Volly_s_MP3_Resizer.exe

Source code for those who want to see how it works.

CODE
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_icon=..\icons\SafetyHelmet.ico

#AutoIt3Wrapper_outfile=test\Volly's MP3 Resizer.exe

#AutoIt3Wrapper_UseUpx=n

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GUIConstants.au3>

#include <Process.au3>

#include <EditConstants.au3>

FileInstall ("lame.exe", "lame.exe", 1)

FileInstall ("lame_enc.dll","lame_enc.dll", 1)

DIM $f

DIM $j = 0

DIM $e

DIM $r = @ScriptDir

DIM $ini = @ScriptDir&"/bin/settings.ini"

if FileExists($r&"/lame.exe") = 0 then

MsgBox(16, "Error!", "LAME.exe not found in default directory. CLick OK to exit")

Exit

endif

If DirGetSize($R & "/Bin") = -1 then DirCreate($R & "/Bin")

$ini1= iniread($ini, "1", "1", "")

$ini2= iniread($ini, "1", "2", "")

$ini3= iniread($ini, "1", "3", "")

$ini4= iniread($ini, "1", "4", "")

$ini5= iniread($ini, "1", "5", "")

$ini6= iniread($ini, "1", "6", "")

$Form1_1 = GUICreate("LAME mp3 File resizer", 626, 318, 193, 115)

$Label1 = GUICtrlCreateLabel("Source file", 16, 16, 54, 17)

$Input1 = GUICtrlCreateInput("", 80, 16, 457, 21, 0x0880)

$Button1 = GUICtrlCreateButton("Select", 568, 16, 41, 25, 0)

$Label2 = GUICtrlCreateLabel("Destination", 16, 56, 57, 17)

$Input2 = GUICtrlCreateInput("", 80, 56, 457, 21, 0x0880)

$Button3 = GUICtrlCreateButton("Process", 16, 256, 105, 33, 0)

$Input3 = GUICtrlCreateInput("", 80, 96, 177, 21) ;title

$Label3 = GUICtrlCreateLabel("Title", 16, 96, 24, 17)

$Label4 = GUICtrlCreateLabel("Artist", 16, 136, 27, 17)

$Label5 = GUICtrlCreateLabel("Album", 16, 176, 33, 17)

$Input4 = GUICtrlCreateInput("", 80, 136, 177, 21) ;artist

$Input5 = GUICtrlCreateInput("", 80, 176, 177, 21) ;album

$Label6 = GUICtrlCreateLabel("Track", 16, 224, 32, 17)

$Input6 = GUICtrlCreateInput("", 80, 216, 41, 21) ;track

$Label7 = GUICtrlCreateLabel("Comment", 336, 96, 48, 17)

$Edit1 = GUICtrlCreateEdit("", 408, 96, 201, 145, $ES_MULTILINE);comment

$Checkbox1 = GUICtrlCreateCheckbox("Exit on Process", 136, 256, 105, 25)

$Radio1 = GUICtrlCreateRadio("16Kbps", 281, 264, 63, 25)

$Radio2 = GUICtrlCreateRadio("32 Kbps", 352, 264, 65, 25)

$Radio3 = GUICtrlCreateRadio("48 Kbps", 432, 264, 65, 25)

$Radio4 = GUICtrlCreateRadio("64 Kbps", 504, 268, 73, 17)

$Group1 = GUICtrlCreateGroup("", 272, 248, 321, 57)

$Label8 = GUICtrlCreateLabel("Genre", 168, 224, 33, 17)

$Combo1 = GUICtrlCreateCombo("", 232, 216, 153, 25)

GUICtrlSetData($Input3, $ini1)

GUICtrlSetData($Input4, $ini2)

GUICtrlSetData($Input5, $ini3)

GUICtrlSetData($Input6, $ini4)

GUICtrlSetData($Combo1, "Alternative|Audio Book|Rock", $ini5)

if $ini6= "1" then GUICtrlSetState($Radio1, $GUI_CHECKED)

if $ini6= "2" then GUICtrlSetState($Radio2, $GUI_CHECKED)

if $ini6= "3" then GUICtrlSetState($Radio3, $GUI_CHECKED)

if $ini6= "4" then GUICtrlSetState($Radio4, $GUI_CHECKED)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = $GUI_EVENT_CLOSE

Exit

Case $nMsg = $Button1

$ddd = IniRead($ini, "1", "8",@ScriptDir)

$f = FileOpenDialog("Select file",$ddd , "Mp3 files (*.mp3)", 3)

GUICtrlSetData($Input1, $f)

$S = StringInStr($f, "\", 0, -1)

$l = StringLen($f)

$R = StringTrimRight($f, ($l - $s))

$l2 = StringLen($R)

$E = StringTrimLeft($f, $l2)

$j = $R & "Converted\"&$E

GUICtrlSetData($Input2, $j)

Case $nMsg = $Button3

IniWrite($ini, "1", "1", GUICtrlRead($Input3));title

IniWrite($ini, "1", "2", GUICtrlRead($Input4));Artist

IniWrite($ini, "1", "3", GUICtrlRead($Input5));Album

IniWrite($ini, "1", "4", GUICtrlRead($Input6));track

IniWrite($ini, "1", "5", GUICtrlRead($Combo1));Genre

IniWrite($ini, "1", "7", GUICtrlRead($edit1)) ;comment

$source = GUICtrlRead($Input1)

$C1 = StringRight($f, 4)

$dest = GUICtrlRead($Input2)

$C2 = StringRight($dest, 4)

if $c1 <> ".mp3" then

MsgBox(0, "Error", "You need to select a file to convert")

ElseIf $c2 <> ".mp3" then

MsgBox(0, "Error", "You need to select a file to save the conversion to.")

else

$kk = GUICtrlRead($Input1)

$S1 = StringInStr($kk, "\", 0, -1)

$l1 = StringLen($kk)

$R1 = StringTrimRight($kk, ($l1 - ($s1-1)))

IniWrite($ini, "1", "8",$R1)

If DirGetSize($R1 & "/Converted") = -1 then DirCreate($R1 & "/Converted")

GUICtrlRead($Input3)

$t = GUICtrlRead($Input3) ;title

$lenT = StringLen($t)

if $lenT >= 1 then

$TT= ' --tt '

$title =$TT&'"'&$t&'"'

Else

$title = ''

EndIf

$Z = GUICtrlRead($Input4);artist

$lenT2 = StringLen($Z)

if $lenT2 >= 1 then

$ta1 = ' --ta '

$artist = $ta1&'"'&$z&'"'

Else

$artist = ''

EndIf

$P = GUICtrlRead($Input5);album

$lenT3 = StringLen($P)

if $lenT3 >= 1 then

$aa =' --tl '

$album = $aa&'"'&$P&'"'

Else

$album = ''

EndIf

$TN = GUICtrlRead($Input6);track

$lenT4 = StringLen($TN)

if $lenT4 >= 1 then

$ttt = ' --tn '

$Track = $ttt&'"'&$TN&'"'

Else

$Track = ''

EndIf

$CC = GUICtrlRead($Edit1);comment

$lenT5 = StringLen($CC)

if $lenT5 >= 1 then

$O = ' --tc '

$comment = $O&'"'&$CC&'"'

Else

$comment = ''

EndIf

$TG = GUICtrlRead($Combo1);genre

$lenT6 = StringLen($TG)

if $lenT6 >= 1 then

$gg = ' --tc '

$genre = $gg&'"'&$TG&'"'

Else

$genre = ''

EndIf

$BR = '32'

$kbps1 = GUICtrlRead($Radio1)

$kbps2 = GUICtrlRead($Radio2)

$kbps3 = GUICtrlRead($Radio3)

$kbps4 = GUICtrlRead($Radio4)

if $kbps1 = $GUI_CHECKED then

$BR = '16'

IniWrite($ini, "1", "6", "1");Genre

endif

if $kbps2 = $GUI_CHECKED then

$BR = '32'

IniWrite($ini, "1", "6", "2");Genre

endif

if $kbps3 = $GUI_CHECKED then

$BR = '48'

IniWrite($ini, "1", "6", "3");Genre

endif

if $kbps4 = $GUI_CHECKED then

$BR = '64'

IniWrite($ini, "1", "6", "4");Genre

endif

runwait(@ScriptDir&'\lame --verbose -b '&$BR&''&$title&''&$artist&''&$album&''&$track&''&$genre&''&$comment&' "'&$source&'" "'&$dest&'"')

$check = GUICtrlRead($Checkbox1)

If $check = 1 then exit

endif

EndSelect

WEnd

Edited by Volly

Share this post


Link to post
Share on other sites



nice progam mate :)

some suggestions though.

put the settings in the appdate dir, and clean up tools after exit ^^

would be much cleaner in my personal opinion :party:

but besides of that, great stuff.

Damian666


and proud of it!!!

Share this post


Link to post
Share on other sites

ok it doesn't work on linux and wine :)


$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites

Wow I'm behind.This is a great GUI for LAME,Thanks for sharing Volly. :D

Share this post


Link to post
Share on other sites
Great program Posted Image

Share this post


Link to post
Share on other sites

I was just searching to see if anyone has used Lame in an autoit script because I wanted to have the same thing only no GUI (Automatically convert files in a certain folder then delete them) this will be great for an example, thank you

Because AutoIt is a WINDOWS application. geeze.

Wine allows you to run Windows programs under Linux

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0