【问题标题】:Disable output in subprocess call ffmpeg在子进程调用ffmpeg中禁用输出
【发布时间】:2021-09-25 00:22:17
【问题描述】:

我目前在 python 中使用以下命令将我的 .webm 文件转换为 .ogg

subprocess.call(['ffmpeg', '-i', songfile, songfile + ".ogg"])

这会打印出一堆我不需要的输出,但我无法使用此命令禁用它。

subprocess.call(['ffmpeg', ' -loglevel quiet','-i', songfile, songfile + ".ogg"])

我得到错误

Unrecognized option '-log-level quiet'.

如何在此处禁用 ffmpeg 输出?

【问题讨论】:

    标签: python ffmpeg subprocess call


    【解决方案1】:

    subprocess.calldocs 说

    要禁止 stdout 或 stderr,请提供值 DEVNULL

    所以你可以替换

    subprocess.call(['ffmpeg', '-i', songfile, songfile + ".ogg"])
    

    使用

    subprocess.call(['ffmpeg', '-i', songfile, songfile + ".ogg"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
    

    【讨论】:

      【解决方案2】:

      Daweo's answer 值得一看,但这就是您的尝试没有成功的原因:请记住,当您执行 subprocess.call 时不涉及 shell(除非您明确要求它),这意味着您需要通过-loglevel quiet 作为两个单独的项目; ..., '-loglevel', 'quiet', ...

      【讨论】:

        猜你喜欢
        • 2021-07-15
        • 2014-11-15
        • 2015-01-13
        • 1970-01-01
        • 2012-05-22
        • 2014-04-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多