0

This code works fine:

cmd = "ffmpeg -y -loop 1 -i " + url1 + " -ss 0 -t 5 " + " - 
filter_complex" + " 
[0:v]scale=w=-2:h=3*720,crop=w=3*1080/1.2:h=3*720/1.2:y=t*in_h/5- 
t*out_h/5,scale=w=1080:h=720 " + " -c:v h264 -crf 18 -preset veryfast 
" + url2

os.system(cmd)

But after executing the below code:

cmd = "ffmpeg -y -loop 1 -i " + url1 + " -ss 0 -t 5 " + " - 
filter_complex" + " 
[0:v]scale=w=-2:h=3*720,crop=w=3*1080/1.2:h=3*720/1.2:y=(in_h-out_h)- 
t*(in_h-out_h)/5,scale=w=1080:h=720 " + " -c:v h264 -crf 18 -preset 
veryfast " + url2

os.system(cmd)

I get an error:

**sh: 1: Syntax error: "(" unexpected****

So it is having a problem with the parentheses. Is there any way to fix it?

1 Answer 1

1

Parentheses have a special meaning to the shell. You can either protect them using a backslash (which you'd have to double: \\(in_h-out_h\\)), or you can put that whole sequence in single quotes:

... + "'[0:v]scale=w=-2:h=3720,crop=w=31080/1.2:h=3720/1.2:y=(in_h-out_h)-t(in_h-out_h)/5,scale=w=1080:h=720'" + ...
Sign up to request clarification or add additional context in comments.

Comments

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.