Last active
January 28, 2022 16:32
-
-
Save woehrl01/68b8908b3d160d982cf5bdae349a1499 to your computer and use it in GitHub Desktop.
Convert Video to Mp3 with Powershell and VLC Player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#based on http://www.andrewconnell.com/blog/Converting-all-your-non-MP3-files-to-MP3s-with-VLC-PowerShell-and-TagLib | |
#don't worry if there are errors shown in VLC this is perfectly fine. | |
#there isn't any progress shown. Simply wait for completion. | |
function ConvertToMp3 ($inputObject, [switch]$isRemoveOldFile = $false) | |
{ | |
$vlc = "C:\Program Files\VideoLAN\VLC\vlc.exe" | |
$codec = 'mp3'; | |
$oldFile = $inputObject; | |
$newFile = $inputObject.FullName.Replace("'", "\'").Replace($inputObject.Extension, ".$codec") | |
write-host $newFile | |
&"$vlc" -I dummy "$oldFile" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst='\$newFile'}" vlc://quit | out-null | |
if($isRemoveOldFile){ | |
Remove-Item $oldFile; | |
} | |
} | |
function ConvertAllToMp3([string] $sourcePath, [switch] $isRemoveOldFile = $false) { | |
write-host $sourcePath | |
Get-ChildItem "$sourcePath\*" -recurse -include *.mp4 | %{ ConvertToMp3 $_ $isRemoveOldFile} | |
} | |
ConvertAllToMp3 [path]; |
It does not work, something is blocking, but no errors. If I do the conversion from the gui vlc, it just works. I am using version 3.0.11
Vielleicht hast du noch ne Idee?
If not, I can use ffmpeg.
@tik9 there is no output, it "just takes a while", so it looks blocked. Does calling the command line without the script, work for you?
In Lin12:
Where is the $_ from? I get null.
@tik9 that's strange, looks like I uploaded a bad version. It should be $inputObject
of course on both places. Thank you for the hint!
Hi, I should be able to see vlc in the taskmanager, shouldn't I?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, the
$_
is the iterator variable of the powershellfor-each
. Which is expressed here by the%
command.