Advertisement
Citylogic

Powershell: Convert WAV's to MP3 Files

May 31st, 2018
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #script requires VLC to be installed
  2. #does not like apostrophes in filename
  3. #Bit rates range from 96 to 320 kilobytes per second (Kbps). Using a bit rate of 128 Kbps usually results in a sound quality equivalent to #what you'd hear on the radio. Many music sites and blogs urge people to use a bit rate of 160 Kbps or higher if they want the MP3 file to #have the same sound quality as a CD.
  4.  
  5. $outputExtension = ".mp3"
  6. $bitrate = 320
  7. $channels = 2
  8.  
  9. foreach($inputFile in get-childitem -recurse -Filter *.wav)
  10. {
  11.  $outputFileName = [System.IO.Path]::GetFileNameWithoutExtension($inputFile.FullName) + $outputExtension;
  12.  $outputFileName = [System.IO.Path]::Combine($inputFile.DirectoryName, $outputFileName);
  13.  
  14.  $programFiles = ${env:ProgramFiles(x86)};
  15.  if($programFiles -eq $null) { $programFiles = $env:ProgramFiles; }
  16.  
  17.  $processName = $programFiles + "\VideoLAN\VLC\vlc.exe"
  18.  $processArgs = "-I dummy -vvv `"$($inputFile.FullName)`" --sout=#transcode{acodec=`"mp3`",ab=`"$bitrate`",`"channels=$channels`"}:standard{access=`"file`",mux=`"wav`",dst=`"$outputFileName`"} vlc://quit"
  19.  
  20.  start-process $processName $processArgs -wait
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement