Captain_Zaraki
Captain_Zaraki

Reputation: 17

ffmpeg syntax error while executing the command

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?

Upvotes: 0

Views: 457

Answers (1)

Tim Roberts
Tim Roberts

Reputation: 54867

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'" + ...

Upvotes: 1

Related Questions