1

I was working through this answer to an FFMPEG question and the command works just fine through the Windows 10 command prompt (I've only changed the input and output filenames):

ffmpeg -i test.mp4  -filter:v "select='gt(scene,0.4)',showinfo" -f null  - 2> test.txt

My Python 3 script gives arguments (as a list) to the subprocess.call() function and works fine for a number of basic FFMPEG operations, but not this one! It seems to be failing at the final null - 2> test.txt part, with the following error messages depending on how I split the arguments:

[NULL @ 000001c7e556a3c0] [error] Unable to find a suitable output format for 'pipe:'
[error] pipe:: Invalid argument

[error] Unrecognized option '2> test.txt'.
[fatal] Error splitting the argument list: Option not found

[error] Unrecognized option '2>'.
[fatal] Error splitting the argument list: Option not found

Here's the basic list of arguments I've been trying:

args=['C:\\Program Files\\ffmpeg\\ffmpeg.exe',
      '-i',
      'test.mp4',
      '-filter:v "select=\'gt(scene,0.4)\',showinfo"',
      '-f null',
      '-',
      '2>',
      'test.txt']

Plus various permutations combining and splitting the last few elements.

Please could somebody help me with the right syntax for running FFMPEG with these arguments through Python 3?

Many thanks - I just can't see where I'm going wrong :(

2
  • why don't you use a wrapper to ffmpeg instead of calling it externally (which is dangerous). e.g.github.com/kkroening/ffmpeg-python Commented May 8, 2018 at 8:16
  • 1
    Thanks Eypros - would like to hear more about why you think it's "dangerous" please? Ultimately doesn't a wrapper have to call ffmpeg externally itself? It's a good thought but here's my reasoning: 1) I'm learning this fresh and after browsing the very wrapper you mentioned, concluded it'll take as long to learn the wrapper syntax as learn the ffmpeg flags themselves; 2) One less dependency, generally good for future-proofing but also I might want to make this project availabile commercially and don't want to have to double check licensing/copyright conditions etc. Commented May 8, 2018 at 21:05

1 Answer 1

1

This doesn't get to the bottom of what was going wrong in my syntax but the following answer provided me with a workaround, essentially using shell=True and passing all arguments as a combined string: subprocess call ffmpeg (command line)

Here's my updated call:

subprocess.call("ffmpeg -i test.mp4 -filter:v \"select='gt(scene,0.4)',showinfo\" -f null - 2> output.txt",shell=True)

Thanks to the nice people at Pythonista Cafe for finding that one for me :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.