【问题标题】:How to use output file in another powershell command?如何在另一个 powershell 命令中使用输出文件?
【发布时间】:2021-02-10 19:44:37
【问题描述】:

我先用自动编辑器剪掉不动的部分,然后用 Mp4Box 添加我的介绍。

我不知道如何自动使用自动编辑器的输出到 Mp4Box。

这是我目前所拥有的。

Get-ChildItem -Filter *.mp4 | ForEach -Process {mp4box -add c:\intro.mp4 -cat $_ -new $a($_.BaseName + '.mp4') -force-cat && del $_ && auto-editor $a --edit_based_on motion --motion_threshold 0.000001% --no_open}

我尝试添加 $a 以将输出变为变量,但这不起作用。由于 Mp4Box 比自动编辑器快很多,因此我将脚本颠倒过来进行测试。

【问题讨论】:

    标签: powershell ffmpeg mp4box


    【解决方案1】:

    在调用任何使用它的命令之前,您必须在单独的语句中创建变量 $a

    Get-ChildItem -Filter *.mp4 | ForEach {
         $a = $_.BaseName + '.mp4'
         mp4box -add c:\intro.mp4 -cat $_ -new $a -force-cat && 
         del $_ &&
         auto-editor $a --edit_based_on motion --motion_threshold 0.000001% --no_open
    }
    

    我还添加了一些换行符以使代码更具可读性。

    【讨论】:

    • 谢谢!我不得不更改它以在最后删除源文件,现在它可以正常工作了。
    猜你喜欢
    • 2021-09-11
    • 2022-08-14
    • 1970-01-01
    • 2011-03-28
    • 1970-01-01
    • 1970-01-01
    • 2013-11-08
    • 2015-08-18
    • 1970-01-01
    相关资源
    最近更新 更多