using ffmpeg command line with python's subprocess module

Andreas Perstinger andipersti at
Tue Dec 10 13:59:47 CET 2013

iMath <redstone-cold at> wrote:
>we don't have permission to use the temporary file while it has not
>been closed,but when the file is closed , it will be destroyed by
>default(delete=True),but once we set delete=False,then we couldn't
>depend on the convenience of letting the temporary file automatically
>delete itself after it has been used(then we have to delete it later
>by os.remove()) ,thus there is nearly no convenience in creating a
>temporary file or a persistent one when using NamedTemporaryFile.

In your OP you asked for a platform independent solution thus I don't
think it's possible to do what you want if the OS doesn't support
opening a file another time while it's still open.

Otherwise, on my Linux system this works:

>>> import tempfile, subprocess
>>> with tempfile.NamedTemporaryFile() as fp:                                   
...   fp.write(b"foo\nbar\nbaz\n")
...   fp.flush()

Bye, Andreas

More information about the Python-list mailing list