2016-12-28 138 views
0

我试图使用python通过调用子流程ffmpeg为视频添加水印。我的代码:在ffmpeg中找不到选项

command = "C:\\VidMaker\\source\\ffmpeg.win32.exe -i C:\\VidMaker\\kq"+str(i)+".mp4 -i C:\\VidMaker\\1.png -filter_complex" "[0:v]setsar=sar=1[v];[v][1]blend=all_mode='overlay':all_opacity=0.7" "-vcodec libx264 C:\VidMaker\\Res"+str(i)+".mp4" 
subprocess.check_call(command, shell = False) 

结果是:

Unrecognized option 'filter_complex[0:v]setsar=sar=1[v];[v][1]blend=all_mode='overlay':all_opacity=0.7-movflags'. 
Error splitting the argument list: Option not found 
Traceback (most recent call last): 
    File "C:\VidMaker\add.py", line 10, in <module> 
    subprocess.check_call(command, shell = False) 
    File "C:\Python27\lib\subprocess.py", line 186, in check_call 
    raise CalledProcessError(retcode, cmd) 
subprocess.CalledProcessError: Command 'C:\VidMaker\source\ffmpeg.win32.exe -n -i C:\VidMaker\kq2.mp4 -i C:\VidMaker\1.png -filter_complex[0:v]setsar=sar=1[v];[v][1]blend=all_mode='overlay':all_opacity=0.7-movflags +faststart C:\VidMaker\Res2.mp4' returned non-zero exit status 1 
[Finished in 0.4s with exit code 1] 

EDIT1:它没有选项来运行正常:

command = "C:\\VidMaker\\source\\ffmpeg.win32.exe -i C:\\VidMaker\\kq"+str(i)+".mp4 -i C:\\VidMaker\\1.png -filter_complex overlay=10:10 C:\VidMaker\\Res"+str(i)+".mp4" 

用什么选择发生,如何解决谢谢!

EDIT2:我需要这样的呼吁,因为我的VPS不能像我的计算机上运行,​​在我的电脑用成功运行:

subprocess.call(['ffmpeg', 
    '-i', 'funvi 155.mp4', 
    '-i', '1.png', 
    '-filter_complex', "[1:v]format=argb,geq=r='r(X,Y)':a='0.15*alpha(X,Y)'[zork]; [0:v][zork]overlay", 
    '-vcodec', 'libx264', 
    'myresult6.mp4']) 

回答

1

它是串联的字符串字面量:

"A" "B" 

成为“AB”,而不是“AB”,不添加空间。因此,要么在命令行参数之间使用一个带空格的单引号字符串,要么找到另一种存储命令行参数的方式,例如在列表中,然后可以将该列表传递给子进程或稍后准备好运行时的任何内容。

对不起,在手机上。