using ffmpeg command line with python's subprocess module

Chris Angelico rosuav at
Fri Dec 6 15:59:43 CET 2013

On Sat, Dec 7, 2013 at 1:54 AM, iMath <redstone-cold at> wrote:
>     fp=tempfile.NamedTemporaryFile(delete=False)
>     fp.write(("file '"+fileName1+"'\n").encode('utf-8'))
>     fp.write(("file '"+fileName2+"'\n").encode('utf-8'))
>['ffmpeg', '-f', 'concat','-i',, '-c',  'copy', fileName])
>     fp.close()

You need to close the file before getting the other process to use it.
Otherwise, it may not be able to open the file at all, and even if it
can, you might find that not all the data has been written.

But congrats! You have successfully found the points I was directing
you to. Yes, I was hinting that you need NamedTemporaryFile, the .name
attribute, and delete=False. Good job!


More information about the Python-list mailing list