You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ffmpeg-python遇AttributeError:FilterableStream无global_args属性

解决ffmpeg-python中AttributeError: 'FilterableStream' object has no attribute 'global_args'错误

错误原因

.global_args()是ffmpeg-python中FFmpeg类的方法,用于添加全局命令行参数,但你把它调用在了.input()返回的FilterableStream对象上,该对象并不提供这个方法,因此触发属性错误。

修正后的代码

将.global_args()和.overwrite_output()移到.output()之后(.output()会返回FFmpeg对象,支持这两个方法),同时修正文件名中的多余转义符:

(ffmpeg
    .input(self.txtSourcePath.toPlainText())
    .output(
        self.txtDestinationPath.toPlainText() + "/" + self.filename + "_%02d." + self.fileExtension,
        map=0, f='segment', segment_time='100', c='copy')
    .global_args('-progress', 'unix://{}'.format(self.filename))
    .overwrite_output()
    .run()
)

额外说明

  • overwrite_output()本质是添加-y参数,你也可以直接在.output()中传入y=True来替代这个方法,写法更简洁:
    .output(..., y=True)
    
  • 文件名中的\_%02d不需要转义,直接写_%02d即可,避免生成的文件名包含不必要的反斜杠。

内容的提问来源于stack exchange,提问作者vothana

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 20:25:46