PowerShell和=内部&调用参数

时间:2018-03-18 12:21:13

标签: powershell ffmpeg escaping

我正在尝试在powershell脚本中运行以下内容:

ffmpeg.exe -hide_banner -i .\input.mkv -passlogfile input -c:v libvpx-vp9 -b:v 0 -crf 31 -tile-columns 6 -tile-rows 2 -threads 8 -pass 2 -speed 1 -frame-parallel 1 -row-mt 1 -c:a libopus -b:a 256000 -c:s copy -af aformat=channel_layouts=5.1 -auto-alt-ref 1 -lag-in-frames 25 -y output.mkv

这可以直接在cmd或powershell行上正常工作,但如果我尝试在带有&的.ps1内运行它,则不行。我收到以下错误:

Unrecognized option '-hide_banner -i .\input.mkv -passlogfile input -c:v libvpx-vp9 -b:v 0 -crf 31 -tile-columns 6 -tile-rows 2 -threads 8 -pass 2 -speed 1 -frame-parallel 1 -row-mt 1 -c:a libopus -b:a 256000 -c:s copy -auto-alt-ref 1 -lag-in-frames 25 -y -af aformat=channel_layouts=5.1 output.mkv'. Error splitting the argument list: Option not found

挖掘一下似乎双-= -af afilter = channel_layouts = 5.1正在惹恼PowerShell,我不知道如何绕过它。已经尝试过以某种方式逃避它而没有运气。

有没有办法可以将这些参数传递给我的exe而没有powershell抱怨无法拆分参数?不知道shell无论如何都要尝试它,因为它首先应该全部转到我的ffmpeg.exe。

2 个答案:

答案 0 :(得分:0)

尝试在--%之后传递命令行参数(“停止解析符号”):

& ffmpeg.exe --% -hide_banner -i .\input.mkv -passlogfile input -c:v libvpx-vp9 -b:v 0 -crf 31 -tile-columns 6 -tile-rows 2 -threads 8 -pass 2 -speed 1 -frame-parallel 1 -row-mt 1 -c:a libopus -b:a 256000 -c:s copy -af aformat=channel_layouts=5.1 -auto-alt-ref 1 -lag-in-frames 25 -y output.mkv

答案 1 :(得分:0)

我的坏。我只是用输出文件名转储。我试着像这样构造一个输出文件名:

$show.$episode.mkv

无论出于何种原因在命令行上运行。

正确的方法是这样的:

$outfile = $show + "." + "$episode" + ".mkv";

分裂错误让我走错了路。