I'm trying to write a python script to stabilize videos using ffmpeg and the vid.stab library. My problem is that the output file doesn't seem to go through stdout, so using subprocess.Popen() returns an empty variable.
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. (If there's no result specified it defaults to 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.
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. For fopen, pipe:1
is not acceptable. For Windows, CON
, and for linux, /dev/stdout
, as you confirmed, is required.