Reputation: 405
I tried to add watermark to a video using python by call subprocess ffmpeg. My code:
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)
the result is:
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: it run ok without option:
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"
What happen with the option and how can fix it?Thanks!
edit2: i need to call like that because my VPS cannot run like my computer, in my computer it run successfully with:
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'])
Upvotes: 0
Views: 3841
Reputation: 40305
It is concatenating your string literals:
"A" "B"
Becomes "AB", not "A B", no space is added. So either use one single quoted string with spaces between your command line parameters, or find another way to store command line parameters, e.g. in a list, then you can pass that list to subprocess or whatever later when you're ready to run it.
Sorry to be brief, on phone.
Upvotes: 1