2016-12-28 137 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」,不添加空間。因此,要麼在命令行參數之間使用一個帶空格的單引號字符串,要麼找到另一種存儲命令行參數的方式,例如在列表中,然後可以將該列表傳遞給子進程或稍後準備好運行時的任何內容。

對不起,在手機上。