0

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.

circo
  • 166
  • 1
  • 9
  • can't you just output the data with ffmpeg as an actual file, and read it in with python? – user3469811 Mar 24 '19 at 12:40
  • That's how I'm doing it currently, but I was wondering if there was a way to avoid that. – circo Mar 24 '19 at 12:46
  • `-f fmt (input/output): Force input or output file format. The format is normally auto detected for input files and guessed from the file extension for output files, so this option is not needed in most cases.` maybe you have to set -f argument, because you do not explicitly produce an output file – user3469811 Mar 24 '19 at 13:04
  • Which OS is this? – Gyan Mar 24 '19 at 15:20
  • @user3469811 there's already an explicit output - it's pipe:1 in this case. But that output is empty, the generated comes from the result filter. The -f null is used to specify that there's no file extension, as nothing is generated there because stdout is empty. – circo Mar 24 '19 at 15:29
  • @Gyan Ubuntu 18.10 – circo Mar 24 '19 at 15:31
  • Add `result=dev/stdout` as a filter argument and check. On Windows, `result=CON` worked for me. The filter is using fopen, so you need a string that on your system points to fd 1 of your child process. – Gyan Mar 24 '19 at 15:33

1 Answers1

2

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.

Gyan
  • 85,394
  • 9
  • 169
  • 201