subprocess module

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • placid

    #1

    subprocess module

    Hi all,

    ive been trying to create a thumbnail using the ffmpeg converter
    running the ffmpeg.exe using the subprocess module with the following
    code
    >>import subprocess
    >>p = subprocess.Pope n(["ffmpeg.exe -i video.mpg", "-f mjpeg -ss 5 -vframes 1 -s 160x120 -an video.gif"], shell=True, stdout=subproce ss.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?


    Cheers

  • Nick Craig-Wood

    #2
    Re: subprocess module

    placid <Bulkan@gmail.c omwrote:
    >import subprocess
    >p = subprocess.Pope n(["ffmpeg.exe -i video.mpg", "-f mjpeg -ss 5 -vframes 1 -s 160x120 -an video.gif"], shell=True, stdout=subproce ss.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.Pope n(args, shell=True, stdout=subproce ss.PIPE)

    or

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

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

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

    Comment

    Working...