Powershell: Convert WAV's to MP3 Files

in #powershell7 years ago (edited)

The following powershell script converts via VLC the WAV's in the current directory to MP3 files. It doesn't like apostrophes in the filename. You'll need windows VLC to run via Powershell and you'll need to set the execution policy to "Unrestricted".

You can verify the execution policy setting by using the Get-ExecutionPolicy PowerShell command: get-executionpolicy

Then:

set-executionpolicy unrestricted

The following is the script, copy paste and save in notepad as "convertWAVtoMP3.ps1" or whatever you prefer.

------------------------------------------------------

$outputExtension = ".mp3"
$bitrate = 320
$channels = 2

foreach($inputFile in get-childitem -recurse -Filter *.wav)
{
$outputFileName = [System.IO.Path]::GetFileNameWithoutExtension($inputFile.FullName) + $outputExtension;
$outputFileName = [System.IO.Path]::Combine($inputFile.DirectoryName, $outputFileName);

$programFiles = ${env:ProgramFiles(x86)};
if($programFiles -eq $null) { $programFiles = $env:ProgramFiles; }

$processName = $programFiles + "\VideoLAN\VLC\vlc.exe"
$processArgs = "-I dummy -vvv "$($inputFile.FullName)" --sout=#transcode{acodec="mp3",ab="$bitrate","channels=$channels"}:standard{access="file",mux="wav",dst="$outputFileName"} vlc://quit"

start-process $processName $processArgs -wait
}

------------------------------------------------------

Anyway with VideoDownloadHelper you can save youtube video's to MP4 then convert to WAV file then to MP3.

Links:

Pastebin: https://pastebin.com/ZR7kywBS
VLC: https://www.videolan.org/vlc/download-windows.html
VideoDownloadHelper: https://addons.mozilla.org/en-US/firefox/addon/video-downloadhelper/

Sort:  

Hi Passing by and Upvoted you :) !
:
“Looking but not seeing is the hearing but not understanding of the eye.” ====> Mokokoma Mokhonoana

Congratulations @citylogic! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last announcement from @steemitboard!

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!