mannworks00 Posted August 26, 2016 Posted August 26, 2016 (edited) I looked everywhere for this and couldn't find it, so I'm posting here. This is a Lame conversion with progress (You need to download lame.exe and lame_enc.dll). Percentage tracker could be improved -- suggestions welcome: Local $fileIn="something.wav,$fileOut="something.mp3",$artist="test",$title="test", ProgressOn("Mp3 Conversion", $fileIn) Local $enc = Run('lame.exe --nohist -b 128 --cbr --noreplaygain -s 44.1 --ta "'&$artist&'" --tt "'&$title&'" --id3v1-only "'&$fileIn&'" "'&@ScriptDir&'\Temp\'&$fileOut&'"',"",@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) Local $line = "" while(ProcessExists($enc)) Sleep(200) $line = StderrRead($enc) If StringLen($line) > 0 Then if StringInStr($line,"25%") <> 0 Then ProgressSet(25," 25 percent") Sleep(750) EndIf if StringInStr($line,"50%") <> 0 Then ProgressSet(50," 50 percent") Sleep(750) EndIf if StringInStr($line,"75%") <> 0 Then ProgressSet(75," 75 percent") Sleep(750) EndIf if StringInStr($line,"100%") <> 0 Then ProgressSet(100, " 100 percent") Sleep(750) EndIf EndIf WEnd ProcessWaitClose($enc) ProgressOff() Edited August 26, 2016 by Melba23
Moderators Melba23 Posted August 26, 2016 Moderators Posted August 26, 2016 mannworks00, Welcome to the AutoIt forums. But in future please do not hijack 9-year old threads - just a start a new one as I have now done for you. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
mannworks00 Posted February 7, 2019 Author Posted February 7, 2019 Sorry Melba23 and Thank you for the welcome!
Nine Posted February 7, 2019 Posted February 7, 2019 How about the size of the mp3 ? Does the size increase continuously ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Bilgus Posted February 8, 2019 Posted February 8, 2019 Here is what I came up with expandcollapse popup;Lame Encoder mannworks00 #include <Misc.au3> #include <File.au3> #include <AutoItConstants.au3> #include <Array.au3> OnAutoItExitRegister("_Exit") Global $g_bStop = False Global Const $g_sWavDir = "C:\Audio_Wav" Global $g_hUser32 = DllOpen("user32.dll") Local $aFileList = _FileListToArray($g_sWavDir, "*.wav") If IsArray($aFileList) Then ProgressOn("Mp3 Conversion ", "", "", 0, 0, BitOr($DLG_NOTONTOP, $DLG_MOVEABLE)) For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) Mp3Encode($i, $aFileList[0], $aFileList[$i], False, "", "", 160) If $g_bStop OR _IsPressed("1B", $g_hUser32) Then Exit EndIf Next EndIf Func Mp3Encode($iCur, $iCt, $sFileIn, $bDeleteSource, $sArtist = "", $sTitle = "", $iBitrate = 120) Local $sFileName = $sFileIn Local $sFileOut = $g_sWavDir & "\" & StringReplace($sFileIn, ".wav", ".mp3", -1) $sFileIn = $g_sWavDir & "\" & $sFileIn Local $aTrackTag if $sArtist = "" and $sTitle = "" Then $aTrackTag = StringRegExp($sFileName, "\\?(.*)\s-\s(.*).wav", 1) If IsArray($aTrackTag) Then $sArtist = $aTrackTag[0] $sTitle = $aTrackTag[1] ConsoleWrite("Artist: " & $sArtist & " Title: " & $sTitle & @CRLF) Else Return EndIf Endif ProgressSet(0, " " & $iCur & "\" & $iCt, $sFileName) Local $hEnc = Run('lame.exe --nohist -b '& $iBitrate & ' --cbr --noreplaygain -q 0 -s 44.1 --priority 3 ' & _ '--ta "' & $sArtist & '" --tt "' & $sTitle & '" --id3v1-only "' & $sFileIn & '" "' & $sFileOut & '"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $aProgress, $iProgress While (ProcessExists($hEnc)) If _IsPressed("1B", $g_hUser32) Then $g_bStop = True EndIf Sleep(500) $aProgress = StringRegExp(StderrRead($hEnc), ".*\(\D?(\d*)%\)", 1) If IsArray($aProgress) Then ProgressSet($aProgress[0]) WEnd ProcessWaitClose($hEnc) If $bDeleteSource And FileExists($sFileOut) And FileGetSize($sFileOut) > 0 Then FileDelete($sFileIn) EndIf EndFunc ;==>Mp3Encode Func _Exit() ProgressOff() DllClose($g_hUser32) EndFunc ;==>_Exit
Bilgus Posted February 8, 2019 Posted February 8, 2019 And one more that can run multiple instances to speed up the conversion expandcollapse popup;Lame Encoder mannworks00 #include <Misc.au3> #include <File.au3> #include <WinAPISys.au3> #include <WinAPIProc.au3> #include <AutoItConstants.au3> #include <ProcessConstants.au3> #include <Array.au3> OnAutoItExitRegister("_Exit") Global $g_bStop = False Global Const $g_sWavDir = "C:\Audio_WAV" Global $g_hUser32 = DllOpen("user32.dll") Local $aFileList = _FileListToArray($g_sWavDir, "*.wav") If IsArray($aFileList) Then ProgressOn("Mp3 Conversion ", "", "", 0, 0, BitOR($DLG_NOTONTOP, $DLG_MOVEABLE)) For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) Mp3Encode($i, $aFileList[0], $aFileList[$i], False, "", "", 160) If $g_bStop Or _IsPressed("1B", $g_hUser32) Then Exit EndIf Next EndIf Func Mp3Encode($iCur, $iCt, $sFileIn, $bDeleteSource, $sArtist = "", $sTitle = "", $iBitrate = 120) Local $sFileName = $sFileIn Local $sFileOut = $g_sWavDir & "\" & StringReplace($sFileIn, ".wav", ".mp3", -1) $sFileIn = $g_sWavDir & "\" & $sFileIn If (Not FileExists($sFileIn)) or FileExists($sFileOut) Then Return Local $aTrackTag If $sArtist = "" And $sTitle = "" Then $aTrackTag = StringRegExp($sFileName, "\\?(.*)\s-\s(.*).wav", 1) If IsArray($aTrackTag) Then $sArtist = $aTrackTag[0] $sTitle = $aTrackTag[1] ConsoleWrite("Artist: " & $sArtist & " Title: " & $sTitle & @CRLF) Else Return EndIf EndIf ProgressSet(0, " " & $iCur & "\" & $iCt, $sFileName) Local $hEnc = Run('lame.exe --nohist -b ' & $iBitrate & ' --cbr --noreplaygain -q 0 -s 44.1 --priority 3 ' & _ '--ta "' & $sArtist & '" --tt "' & $sTitle & '" --id3v1-only "' & $sFileIn & '" "' & $sFileOut & '"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ConsoleWrite(SetProcessAffinity(0, $hEnc) & @crlf) Local $aProgress, $iProgress While (ProcessExists($hEnc)) If _IsPressed("1B", $g_hUser32) Then $g_bStop = True EndIf Sleep(500) $aProgress = StringRegExp(StderrRead($hEnc), ".*\(\D?(\d*)%\)", 1) If IsArray($aProgress) Then ProgressSet($aProgress[0]) WEnd ProcessWaitClose($hEnc) If $bDeleteSource And FileExists($sFileOut) And FileGetSize($sFileOut) > 0 Then FileDelete($sFileIn) EndIf EndFunc ;==>Mp3Encode Func _Exit() ProgressOff() DllClose($g_hUser32) EndFunc ;==>_Exit Func SetProcessAffinity($iAffinityMask = 0, $iPID = @AutoItPID) Local $sRetn = "Skipping Affinity" & @CRLF Local $hProcess If _WinAPI_GetVersion() >= 6.0 Then $hProcess = _WinAPI_OpenProcess(BitOR($PROCESS_SET_INFORMATION, $PROCESS_QUERY_LIMITED_INFORMATION), 0, $iPID) Else $hProcess = _WinAPI_OpenProcess(BitOR($PROCESS_SET_INFORMATION, $PROCESS_QUERY_INFORMATION), 0, $iPID) EndIf If Not $hProcess Then Return "Couldn't Get Handle " & _WinAPI_GetLastErrorMessage() & @CRLF If $iAffinityMask = 0 Then Local $aAffinity = _WinAPI_GetProcessAffinityMask($hProcess) If @error Then $sRetn = "Couldn't Get Affinity " & _WinAPI_GetLastErrorMessage() & @CRLF $iAffinityMask = -1 EndIf $iAffinityMask = BitXOR($aAffinity[2], 1) EndIf If $iAffinityMask > 1 Then If Not _WinAPI_SetProcessAffinityMask($hProcess, $iAffinityMask) Then $sRetn = "Couldn't Set Affinity " & _WinAPI_GetLastErrorMessage() & @CRLF Else $sRetn = "Set Affinity Mask " & $iAffinityMask & @CRLF EndIf Else $sRetn &= " " & $iAffinityMask EndIf _WinAPI_CloseHandle($hProcess) Return $sRetn EndFunc ;==>SetProcessAffinity
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now