下面的代码运行良好:
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)但是在执行下面的代码之后:
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)我得到一个错误:
**sh: 1: Syntax error: "(" unexpected****所以它在圆括号上有问题。有没有办法解决这个问题?
发布于 2021-03-12 14:14:45
括号对shell有特殊的意义。您可以使用反斜杠来保护它们(您必须使用双引号:\\(in_h-out_h\\)),也可以将整个序列放在单引号中:
... + "'[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'" + ...https://stackoverflow.com/questions/66595016
复制相似问题