简体   繁体   English

在子进程python中使用ffmpeg

[英]Using ffmpeg with subprocess python

I am trying to download videos from Wistia and I managed to download them but in .bin&amp format ; 我试图从Wistia下载视频,但设法以.bin&amp格式下载了视频; I'd like to convert them to .mp4 in order to use OpenCV. 我想将它们转换为.mp4以便使用OpenCV。 For this I am calling ffmpeg with subprocess on Python but I get 1 as the value for the return code, meaning the process has failed. 为此,我在python上使用子进程调用ffmpeg,但返回值的值为1,这意味着该进程已失败。 Any idea why, and how I can change this...? 知道为什么,以及如何更改此...?

Code is the following: 代码如下:

import subprocess

infile = filename #a bin&amp file
outfile = filename[:-7]+'mp4'

subprocess.run(['ffmpeg', '-i', infile, outfile],shell=True)

I get : 我得到:

CompletedProcess(args=['ffmpeg', '-i', '58c63bccfcc1c150646c261caad97a58ced4b5e3.bin&amp', '58c63bccfcc1c150646c261caad97a58ced4b5e3.mp4'], returncode=1)

Also, it works in the command prompt... 此外,它还可以在命令提示符下运行...

Thank you for your help, 谢谢您的帮助,

Sincerely, 真诚的

Try to use Popen. 尝试使用Popen。 I I'm using FFmpeg in python and it works well 我在python中使用FFmpeg,效果很好

process_ = subprocess.Popen(ffmpeg_cmd, start_new_session=True) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM