0

I would like to run the following command in Powershell: ffmpeg -i "VIDEO.mp4" -i "AUDIO.m4a" -c copy -map 0:v:0 -map 1:a:0 "OUTPUT VIDEO.mp4"

But I would like to browse for the files. I have tried this:

Add-Type -AssemblyName System.Windows.Forms 

$VideoBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ 
    InitialDirectory = $PSCommandPath
    Filter = 'Video file (*.mp4)|*.mp4|All files (*.*)|*.*'
    Title = 'Choose video file'
}
$null = $VideoBrowser.ShowDialog()
if (!($VideoBrowser.FileName))
{
    return
}

$AudioBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ 
    Filter = 'Video file (*.m4a)|*.m4a|All files (*.*)|*.*'
    Title = 'Choose audio file'
    RestoreDirectory = $true
}
$null = $AudioBrowser.ShowDialog()
if (!($AudioBrowser.FileName))
{
    return
}

$NewVideoBrowser = New-Object System.Windows.Forms.SaveFileDialog -Property @{ 
    Filter = 'Video file (*.mp4)|*.mp4|All files (*.*)|*.*'
    Title = 'Save new video file as'
    RestoreDirectory = $true
}
$null = $NewVideoBrowser.ShowDialog()
if (!($NewVideoBrowser.FileName))
{
    return
}

And all these ways to run the command but all fail:

$ArgumentList = '"{0}" -i "{1}" -c copy -map 0:v:0 -map 1:a:0 "{2}"' -f $VideoBrowser.FileName, $AudioBrowser.FileName, $NewVideoBrowser.FileName;
Start-Process -FilePath ffmpeg.exe -ArgumentList $ArgumentList -Wait -NoNewWindow

OR

$ArgumentList = '"' + $VideoBrowser.FileName + '" -i "' + $AudioBrowser.FileName + '" -c copy -map 0:v:0 -map 1:a:0 "' + $NewVideoBrowser.FileName + '"'
Start-Process -FilePath ffmpeg.exe -ArgumentList $ArgumentList -Wait -NoNewWindow

OR ffmpeg.exe $VideoBrowser.FileName -i $AudioBrowser.FileName -c copy -map 0:v:0 -map 1:a:0 $NewVideoBrowser.FileName

What should I try?

1 Answer 1

2

I had forgotten the -i in the beginning of the arguments!

This works: ffmpeg -loglevel debug -i $VideoBrowser.FileName -i $AudioBrowser.FileName -c copy -map 0:v:0 -map 1:a:0 $NewVideoBrowser.FileName

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.