Search code examples
pythoncmd

Running cmd in python


Atm I have this as my code, the first line seems to work well but the 2nd gives errrors.

os.chdir('C://Users/Alex/Dropbox/code stuff/test')
subprocess.call('ffmpeg -i test%d0.png output.avi')

Also when I try to run it as this, it gives a 1s cmd flicker and then nothing happens

os.system('ffmpeg -i test%d0.png output.avi')

Solution

  • For the later generations looking for the answer, this worked. (You have to separate the command by the spaces.)

    import os
    import subprocess
    os.chdir('C://Users/Alex/')
    subprocess.call(['ffmpeg', '-i', 'picture%d0.png', 'output.avi'])
    subprocess.call(['ffmpeg', '-i', 'output.avi', '-t', '5', 'out.gif'])