Skip to content

Instantly share code, notes, and snippets.

@pstakuu
Created August 12, 2022 14:02
Show Gist options
  • Save pstakuu/4c5ca7cc81643b72d0d299caa589bed4 to your computer and use it in GitHub Desktop.
Save pstakuu/4c5ca7cc81643b72d0d299caa589bed4 to your computer and use it in GitHub Desktop.
converts other sound formats to mp3 - can't remember where I grabbed this from but put it together and requires VLC
function ConvertToMp3( $file, [string] $vlc = 'C:\Program Files\VideoLAN\VLC\vlc.exe') {
PROCESS {
$codec = 'mp3';
$oldFile = Get-Item $file;
$newFile = $oldFile.FullName.Replace($oldFile.Extension, ".$codec");
&"$vlc" -I dummy "$oldFile" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst=$newFile}" vlc://quit | out-null;
#Only remove source files when you are sure that the conversion works as you want
#Remove-Item $oldFile;
}
}
$vlc = 'C:\Program Files\VideoLAN\VLC\vlc.exe'
$codec = 'mp3';
$oldFile = Get-Item 'C:\tmep\Sound recordings\Recording (2).m4a'
$newFile = $oldFile.FullName.Replace($oldFile.Extension, ".$codec");
&"$vlc" -I dummy "$oldFile" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst=$newFile}" vlc://quit | out-null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment