想问问我这个 ffmpeg 方法该怎么办 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Canglin
V2EX    Python

想问问我这个 ffmpeg 方法该怎么办

  •  
  •   Canglin 2024-03-24 09:47:39 +08:00 2769 次点击
    这是一个创建于 573 天前的主题,其中的信息可能已经有所发展或是发生改变。

    是这样的,我想在 ffmpeg 输出的时候直接覆盖掉 output_file,在 ffmpeg.output 中也使用了 overwrite 参数但是运行的时候依旧要我手工在 ps 里面输入'y'才能继续执行,想问问各位大哥这个该怎么解决? 使用的包是 ffmpeg-python 内容如下:

    def ffmpeg_process(video_path, audio_path): video_stream = ffmpeg.input(video_path) audio_stream = ffmpeg.input(audio_path) output_path = os.path.join( OUTPUT_PATH, VIDEO_MAP['GROUP_TITLE'], ) output_path = os.path.join(output_path, VIDEO_MAP['OUTPUT_FILE']) output_stream = ffmpeg.output( video_stream, audio_stream, output_path, vcodec='copy', ) def count_none(Map): NOnes= sum(values is None for values in Map.values()) if Nones > 0: return False else: return True if count_none(VIDEO_MAP): Build.makedir(output_path) ffmpeg.run(output_stream) 
    第 1 条附言    2024-03-24 11:42:45 +08:00
    已经解决了,解决办法分两步,第一步创建目录的时候需要赋权否则会出现权限不足的错误,然后使用 ffmpeg.run(output_stream, overwrite_output=True)语句即可
    8 条回复    2024-03-24 10:57:05 +08:00
    wuruorocks
        1
    wuruorocks  
       2024-03-24 10:00:15 +08:00
    ffmpeg 命令行有-y 参数,不知这个 python 包有没有对应的;实在不行就输出到临时文件,然后再 move
    formant
        2
    formant  
       2024-03-24 10:01:10 +08:00 via Android
    vcodec='copy',
    '-y' # 添加这个参数试试?
    liyouran
        3
    liyouran  
       2024-03-24 10:02:03 +08:00
    官方文档 https://ffmpeg.org/ffmpeg.html#Main-options 里有个-y 参数能直接覆盖,我直接用 subprocess 模块运行 ffmpeg
    Canglin
        4
    Canglin  
    OP
       2024-03-24 10:14:03 +08:00
    @formant #2 不行,直接报错了
    Canglin
        5
    Canglin  
    OP
       2024-03-24 10:14:22 +08:00
    @wuruorocks #1 是个简单粗暴的好办法
    chanssl
        6
    chanssl  
       2024-03-24 10:39:55 +08:00
    文: https://kkroening.github.io/ffmpeg-python/# ,有 overwrite_output 的。
    ffmpeg.run(output_stream,overwrite_output=True)
    abccccabc
        7
    abccccabc  
       2024-03-24 10:49:27 +08:00
    @liyouran 这个-y 参数不好用,在我 php 这里会报错。
    Canglin
        8
    Canglin  
    OP
       2024-03-24 10:57:05 +08:00
    @chanssl #6 这个方法我刚试了一下,Error opening output files: Permission denied 提示这个错误
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     882 人在线   最高记录 6679 &nsp;     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 30ms UTC 21:16 PVG 05:16 LAX 14:16 JFK 17:16
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86