subprocess module

P

placid

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.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?


Cheers
 
N

Nick Craig-Wood

placid said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top