是这样的,我想在 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 wuruorocks 2024-03-24 10:00:15 +08:00 ffmpeg 命令行有-y 参数,不知这个 python 包有没有对应的;实在不行就输出到临时文件,然后再 move |
2 formant 2024-03-24 10:01:10 +08:00 via Android vcodec='copy', '-y' # 添加这个参数试试? |
3 liyouran 2024-03-24 10:02:03 +08:00 官方文档 https://ffmpeg.org/ffmpeg.html#Main-options 里有个-y 参数能直接覆盖,我直接用 subprocess 模块运行 ffmpeg |
![]() | 5 Canglin OP @wuruorocks #1 是个简单粗暴的好办法 |
![]() | 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) |