What's the equivalent of cmd for powershell with ffmpeg

社会主义新天地 提交于 2020-11-27 04:27:07

问题


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

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

works in cmd but same on Powershell gives

Unexpected token '-i' in expression or statement.

what's then the right syntax ?


回答1:


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.

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

Or, via an environment variable:

# 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.

The syntactic need for & stems from PowerShell having two fundamental parsing modes and is explained in detail in this answer.



来源:https://stackoverflow.com/questions/64413449/whats-the-equivalent-of-cmd-for-powershell-with-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!