using ffmpeg command line with python's subprocess module

Chris Angelico rosuav at gmail.com
Wed Dec 4 05:51:49 EST 2013


On Wed, Dec 4, 2013 at 8:38 PM, Andreas Perstinger <andipersti at gmail.com> wrote:
> "fp" is a file object, but subprocess expects a list of strings as
> its first argument.

More fundamentally: The subprocess's arguments must include the *name*
of the file. This means you can't use TemporaryFile at all, as it's
not guaranteed to return an object that actually has a file name.

There's another problem, too, and that's that you're not closing the
file before expecting the subprocess to open it. And once you do that,
you'll find that the file no longer exists once it's been closed. In
fact, you'll need to research the tempfile module a bit to be able to
do what you want here; rather than spoon-feed you an exact solution,
I'll just say that there is one, and it can be found here:

http://docs.python.org/3.3/library/tempfile.html

ChrisA



More information about the Python-list mailing list