Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So I have a line here that is meant to dump frames from a movie via python and ffmpeg.

subprocess.check_output([ffmpeg, "-i", self.moviefile, "-ss 00:01:00.000 -t 00:00:05 -vf scale=" + str(resolution) + ":-1 -r", str(framerate), "-qscale:v 6", self.processpath + "/" + self.filetitles + "-output%03d.jpg"])

And currently it's giving me the error:

'CalledProcessError: Command ... returned non-zero exit status 1'

The command python SAYS it's running is:

'['/var/lib/openshift/id/app-root/data/programs/ffmpeg/ffmpeg', '-i', u'/var/lib/openshift/id/app-root/data/moviefiles/moviename/moviename.mp4', '-ss 00:01:00.000 -t 00:00:05 -vf scale=320:-1 -r', '10', '-qscale:v 6', '/var/lib/openshift/id/app-root/data/process/moviename/moviename-output%03d.jpg']'

But when I run the following command via ssh...

'/var/lib/openshift/id/app-root/data/programs/ffmpeg/ffmpeg' -i '/var/lib/openshift/id/app-root/data/moviefiles/moviename/moviename.mp4' -ss 00:01:00.000 -t 00:00:05 -vf scale=320:-1 -r 10 -qscale:v 6 '/var/lib/openshift/id/app-root/data/process/moviename/moviename-output%03d.jpg'

It works just fine. What am I doing wrong? I think I'm misunderstanding the way subprocess field parsing works...

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The subprocess module doesn't allow any whitespace characters in its parameters, unless you run it in shell mode. Try this:

subprocess.check_output(["ffmpeg", "-i", self.moviefile, "-ss", "00:01:00.000", "-t", "00:00:05", "-vf", "scale=" + str(resolution) + ":-1", "-r", str(framerate), "-qscale:v", "6", self.processpath + "/" + self.filetitles + "-output%03d.jpg"])
share|improve this answer
    
That's exactly the problem I had with convert (imagemagick) –  Steve K 1 hour ago
    
Thanks so much! This is a clear explanation =D –  Varda Elbereth 1 hour ago

The argument array you pass to check_call is not correctly formatted. Every arguent to ffmpeg needs to be a single element in the argument list, for example

... "-ss 00:01:00.000 -t 00:00:05 -vf ...

should be

... "-ss", "00:01:00.000", "-t", "00:00:05", "-vf", ...

The complete resulting args array should be:

['ffmpeg', '-i', '/var/lib/openshift/id/app-root/data/moviefiles/moviename/moviename.mp4', '-ss', '00:01:00.000', '-t', '00:00:05', '-vf', 'scale=320:-1', '-r', '10', '-qscale:v', '6', '/var/lib/openshift/id/app-root/data/process/moviename/moviename-output%03d.jpg']
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.