ffmpeg相当于Powershell的cmd [英] What's the equivalent of cmd for powershell with ffmpeg

查看:110
本文介绍了ffmpeg相当于Powershell的cmd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 https://www.poftut.com/ffmpeg-command-tutorial-examples-video-audio/

ffmpeg -i jellyfish-3-mbps-hd-h264.mkv

可以在cmd中工作,但在Powershell上可以使用

works in cmd but same on Powershell gives

Unexpected token '-i' in expression or statement.

那么正确的语法是什么?

what's then the right syntax ?

推荐答案

如您的问题中当前所示,该命令在PowerShell中可以正常使用.

As currently shown in your question, the command would work just fine in PowerShell.

# OK - executable name isn't quoted.
ffmpeg -i jellyfish-3-mbps-hd-h264.mkv

但是,如果您引用可执行路径,问题就会浮出水面.

However, if you quote the executable path, the problem surfaces.

# FAILS, due to SYNTAX ERROR, because the path is (double)-quoted.
PS> "C:\Program Files\ffmpeg\bin\ffmpeg" -i jellyfish-3-mbps-hd-h264.mkv
Unexpected token '-i' in expression or statement.

出于语法上的原因,PowerShell需要&

For syntactic reasons, PowerShell requires &, the call operator, to invoke executables whose paths are quoted and/or contain variable references or subexpressions.

# OK - use of &, the call operator, required because of the quoted path.
& "C:\Program Files\ffmpeg\bin\ffmpeg" -i jellyfish-3-mbps-hd-h264.mkv

或者通过环境变量:

# OK - use of &, the call operator, required because of the variable reference.
# (Double-quoting is optional in this case.)
& $env:ProgramFiles\ffmpeg\bin\ffmpeg -i jellyfish-3-mbps-hd-h264.mkv

如果您不想考虑何时& 实际上是必需的,则只需始终它.

If you don't want to have to think about when & is actually required, you can simply always use it.

& 语法需求源于PowerShell具有两种基本的解析模式,并且在 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆