我在命令提示符中以低优先级运行FFmpeg。
start /low /b ffmpeg -i "C:\video.mpg" -c:v libx264 -crf 25 "C:\video.mp4"
如何在 PowerShell 中为low
,below normal
,normal
,above normal
,high
设置FFmpeg的优先级? / p>
在PowerShell中使用上面的CMD命令,我得到以下错误:
Parameter cannot be processed because the parameter name 'i' is ambiguous.
Start-Process : A positional parameter cannot be found that accepts argument 'ffmpeg'.
测试解决方案
我正在尝试使用ArcSet答案中的第一个示例。
Start-Process ffmpeg -NoNewWindow -Wait -ArgumentList '-i "C:\video.mpg" -c:v libx264 -crf 25 "C:\video.mp4"' -PassThru Set-ProcessPriority -ProcessId $Process.id -Priority AboveNormal
我遇到了错误:
A positional parameter cannot be found that accepts argument 'Set-ProcessPriority'
答案 0 :(得分:1)
使用以太坊Set-ProcessPriority
$Process = Start-Process "C:\ffmpeg\bin\ffmpeg.exe" -ArgumentList "-i `"C:\ffmpeg\Test\Test.mpg`" -c:v libx264 -crf 25 `"C:\ffmpeg\Test\Test.mp4`"" -PassThru
Set-ProcessPriority -ProcessId $Process.id -Priority BelowNormal
或在进程的属性中设置
($Process = Start-Process "C:\ffmpeg\bin\ffmpeg.exe" -ArgumentList "-i `"C:\ffmpeg\Test\Test.mpg`" -c:v libx264 -crf 25 `"C:\ffmpeg\Test\Test.mp4`"" -NoNewWindow -PassThru).PriorityClass = [System.Diagnostics.ProcessPriorityClass]::BelowNormal
如果您需要验证其设置为您要求的优先级,则可以调用存储过程的变量并进行检查
$Process.PriorityClass
作为旁注,您将看到使用的字符`。这是一个转义字符,因此可以在引号内使用引号
"Hey `"There`" People"
会返回
Hey "There" People