Error convert video to mp3, closing bracket at the end of the resulting file's name

Microsoft Windows specific usage questions
Forum rules
Please post only Windows specific questions in this forum category. If you don't know where to post, please read the different forums' rules. Thanks.
mymicrosoftmylife
New Cone
New Cone
Posts: 3
Joined: 10 Nov 2020 08:26

Error convert video to mp3, closing bracket at the end of the resulting file's name

Postby mymicrosoftmylife » 10 Nov 2020 08:45

Hi.
I have created a Powershell script to help me extract the audio of a video file and output it to a mp3 file. The script worked but there is problem. The resulting output file has a closing bracket at the end of the file's name, that is the file's name is not "example_output_file.mp3" but "example_output_file.mp3}". I hope somebody can give the help.
Here is the script:

Code: Select all

$currentScriptPath = $PSScriptRoot Write-Host "Please press enter and choose the video file you want to extract audio from below" Pause Add-Type -AssemblyName System.Windows.Forms $mediaFileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ Multiselect = $false # Multiple files can be chosen Filter = 'Videos (*.mkv,*.mp4)|*.mkv;*.mp4' # Specified file types } [void]$mediaFileBrowser.ShowDialog() $mediaFilePath = $null; If($mediaFileBrowser.FileNames -like "*\*") { $mediaFilePath = $mediaFileBrowser.FileName; $mediaFileBrowser.FileName #Lists selected files (optional) } Else { Write-Host "Cancelled by user" Exit } $mediaFileName = Split-Path -Path $mediaFilePath -leaf $mediaFileLocation = Split-Path -Path $mediaFilePath $mediaFileBaseName = (Get-Item -literalPath $mediaFilePath).BaseName $newFileSaveDestination = "$mediaFileLocation" + "\" + "[audio] " + $mediaFileBaseName + ".mp3" $inputMediaFileURI = ([system.uri]$mediaFilePath).AbsoluteUri $bitrate = 0 Do{ #ask user to input an integer for the bitrate of the resulting mp3 file Write-Host "Please input the audio bitrate for the extracted mp3 file" $bitrate = Read-Host "Enter the bitrate for the audio of the output file" } #loop the above step until user input an integer greater than 0 Until (($bitrate -match "^\d+$") -and ([Int]$bitrate -gt 0)) $argumentList = "-vvv $inputMediaFileURI --sout=`"#transcode{vcodec=none,acodec=mp3,ab=$bitrate,channels=2,samplerate=44100,scodec=none}:std{access=file{no-overwrite},mux=raw,dst=$newFileSaveDestination}`" --sout-all --sout-keep vlc://quit" $currentTime = Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss.fff K" Write-Host "Begin video audio extract on $currentTime" Start-Process -NoNewWindow -FilePath "C:\Program Files\VideoLAN\VLC\vlc.exe" -ArgumentList "$argumentList" $currentTime = Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss.fff K" Write-Host "Done video audio extract on $currentTime" Write-Host "The new mp3 file can be found at $newFileSaveDestination" Write-Host "Done"
Thanks.

Hitchhiker
Big Cone-huna
Big Cone-huna
Posts: 2203
Joined: 29 Jun 2018 11:40
VLC version: 3.0.17.4
Operating System: Windows 8.1
Location: The Netherlands

Re: Error convert video to mp3, closing bracket at the end of the resulting file's name

Postby Hitchhiker » 10 Nov 2020 12:12

No need to write scripts to extract audio from a video file. You can just use the default Convert menu. See this thread which contains a screenshot of the menu: https://forum.videolan.org/viewtopic.ph ... 65#p510665

mymicrosoftmylife
New Cone
New Cone
Posts: 3
Joined: 10 Nov 2020 08:26

Re: Error convert video to mp3, closing bracket at the end of the resulting file's name

Postby mymicrosoftmylife » 10 Nov 2020 13:27

No need to write scripts to extract audio from a video file. You can just use the default Convert menu. See this thread which contains a screenshot of the menu: https://forum.videolan.org/viewtopic.ph ... 65#p510665
Yeah, I know but I have the work of converting the video downloaded from the net to mp3 often and I don't want to select the thing every time to change the bit rate of the thing, the script helped me save efforts and time. But what I'm asking is what's wrong with these the command in the script so that it didn't output the file with a correct name. Is it a false of me or it's just a glitch in the VLC application. Hope someone know.

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Error convert video to mp3, closing bracket at the end of the resulting file's name

Postby mederi » 10 Nov 2020 14:25



Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: Google [Bot], sventop and 19 guests