简体   繁体   English

使用vid.stab在python中将ffmpeg的输出文件捕获到变量中

[英]Capturing output file of ffmpeg with vid.stab in python into a variable

I'm trying to write a python script to stabilize videos using ffmpeg and the vid.stab library. 我正在尝试编写python脚本,以使用ffmpeg和vid.stab库稳定视频。 My problem is that the output file doesn't seem to go through stdout, so using subprocess.Popen() returns an empty variable. 我的问题是输出文件似乎没有通过stdout,因此使用subprocess.Popen()返回一个空变量。

cmd1=["ffmpeg", "-i","./input.MOV", "-vf", "vidstabdetect=stepsize=6:shakiness=10:accuracy=15", "-f","null","pipe:1"]
p = subprocess.Popen(cmd1, stdout=subprocess.PIPE)
vectors, err = p.communicate()

The issues is that vibstabdetect takes a filter called result, and outputs a file to whatever's specified there, and stdout remains empty. 问题是vibstabdetect接受一个名为result的过滤器,并将文件输出到在那里指定的文件,并且stdout保持为空。 (If there's no result specified it defaults to transforms.trf.) (如果没有指定结果,则默认为transforms.trf。)

Is there a way to get the contents of the result file? 有没有办法获取结果文件的内容? When running the script with the code above it executes without error, but the file is created with the default name and the variable remains empty. 当使用上面的代码运行脚本时,脚本将无错误执行,但是将使用默认名称创建文件,并且变量保持为空。

You need to specify stdout for the filter logging data, not the transcoded output from ffmpeg, which is what your current -f null pipe:1 does. 您需要为过滤器日志记录数据指定stdout,而不是ffmpeg的转码输出,这就是您当前的-f null pipe:1所做的。

However, the vidstabdetect filter uses the POSIX fopen to open the destination for the transform data, unlike most other filters which use the internal avio_open. 但是,与使用内部avio_open的大多数其他过滤器不同,vidstabdetect过滤器使用POSIX fopen打开转换数据的目标。 For fopen, pipe:1 is not acceptable. 对于fopen, pipe:1是不可接受的。 For Windows, CON , and for linux, /dev/stdout , as you confirmed, is required. 对于Windows, CON ,对于Linux, /dev/stdout是必需的。

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

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