PowerShell 和 = 在 & 调用参数中

标签 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 的 double = 惹恼了 powershell,我不知道如何解决它。已经尝试以某种方式逃避它,但没有运气。

有什么方法可以将这些类型的参数传递给我的 exe,而无需 powershell 提示无法拆分参数?无论如何,不​​明白shell首先尝试它,因为它首先应该全部转到我的ffmpeg.exe。

最佳答案

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

& 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

关于PowerShell 和 = 在 & 调用参数中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49347816/

相关文章:

Powershell:如何用引号将字符串数组括起来,以便 SQL "IN"运算符起作用?

powershell - 使用PowerShell通过管道将用户添加到组中

java - 将音频作为原始流播放时发出尖锐的白色声音

macos - 转义挂载命令中的特殊字符

c - 是否有用于引用/转义表名的 C SQLite API?

PowerShell if/else 测试路径

powershell - 循环浏览文件夹/文件并替换单词

batch-file - 我如何只回显空白而不回显换行符

android - 如何使用 FFMpeg 获取当前帧

c# - 转义字符问题