subprocess module

Nick Craig-Wood nick at craig-wood.com
Thu Jul 27 05:30:03 EDT 2006


placid <Bulkan at gmail.com> wrote:
> >>> import subprocess
> >>> p = subprocess.Popen(["ffmpeg.exe -i video.mpg", "-f mjpeg  -ss 5 -vframes 1 -s 160x120 -an video.gif"], shell=True, stdout=subprocess.PIPE)
> 
>  but the ffmpeg complains about the input file being corrupter, whereas
>  when i run the same command via the command shell (cmd.exe) it works.
>  Does anyone know what the problem is?

Here is an idea to try: I would say you've mixed up the two styles of
passing arguments, either pass

  args = "ffmpeg.exe -i video.mpg -f mjpeg  -ss 5 -vframes 1 -s 160x120 -an video.gif"
  p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)

or

  args = ['ffmpeg.exe', '-i', 'video.mpg', '-f', 'mjpeg', '', '-ss', '5', '-vframes', '1', '-s', '160x120', '-an', 'video.gif']
  p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)

If you mix the two styles then you are probably heading for trouble
with argument quoting.

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list