Skip to content Skip to sidebar Skip to footer

Piping To FFMPEG With Python Subprocess Freezes

With the following code, I am able to pipe frames of a video to FFMPEG using Python, Numpy and the FFMPEG binaries: from __future__ import print_function import subprocess import n

Solution 1:

A highly probable culprit is the disgustingly stinky subprocess.Popen line. Not only you ignore its return value - which you must never do, in order to ensure the subprocess' completion by certain point and/or check its exit code - you also make stderr a pipe but never read it - so the process must be hanging when its buffer fills.

This should fix it:

p = subprocess.Popen(cmd_out, stdin=subprocess.PIPE)
fout = p.stdin

<...>

fout.close()
p.wait()
if p.returncode !=0: raise subprocess.CalledProcessError(p.returncode,cmd_out)

Post a Comment for "Piping To FFMPEG With Python Subprocess Freezes"