2

I'm trying to call simple ffmpeg command line with subprocess.call. (Example : ffmpeg -i input\video.mp4 -r 30 input\video.avi)

By typing directly the ffmpeg command it works, but when I try to call it with subprocess.call : subprocess.call('ffmpeg -i input\video.mp4 -r 30 input\video.avi', shell=True) there is no error, but it doesn't produce anything.

Any idea where can be the problem? (I'm working with python 3.4 or 2.7, I tried both)

1
  • unrelated: you don't need shell=True on Windows here. Commented Jan 15, 2015 at 16:55

2 Answers 2

3

Finally found the problem : when you are using subprocess you MUST use

/

for your files location instead of

\

EDIT : or you can use raw-string literals -> r'ffmpeg -i input\video.mp4 ...' (notice: r'') or you can double them '\\' Thanks to J.F. Sebastian

Sign up to request clarification or add additional context in comments.

1 Comment

There is nothing special about subprocess. You could use raw-string literals for Windows paths that contain backslashes e.g., r'ffmpeg -i input\video.mp4 ...' (notice: r'') or you should double them '\\'
0
x=subprocess.Popen('ffmpeg -i input\video.mp4 -r 30 input\video.avi', shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output,err=x.communicate()
if output:
      print "success ",output
else:
      print "error ",err

You can try this and check output and errors if any.

4 Comments

With the updated code I have : error b'' (I changed error to err, error wasn't defined)
@Jacqueslelezard your ffmpeg command is not working properly.It is failing with error b.
I see that, but why? If I type exactly the same command without running it from python there is no any problem...
@Jacqueslelezard have you checked the file location?is the script located at correct location?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.