我正在尝试自动连接(格式正确的)mp4 视频文件的文件夹。
(我的问题的这个编辑版本将问题减少到了我困惑的最低水平。原始标题询问了之间的差异subprocess.call
and subprocess.run
但事实证明问题出在其他地方。)
Why does
subprocess.call('ffmpeg -hide_banner -loglevel error -i movie1.mp4 -i movie2.mp4 -i credits.mp4 \
-filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" "output.mp4"',shell=True)
工作正常(其中s
是一串输入,并且count
是输入的数量),但是
#python3
#makeFinalExample.py
import subprocess
s = '-i movie1.mp4 -i movie2.mp4 -i credits.mp4'
count = 3
print(f's prints out as: {s}')
commandList = ['ffmpeg',
'-hide_banner',
'-loglevel',
'error',
#str(s),
'{0}'.format(s),
'-filter_complex',
"[0:v:0][0:a:0][1:v:0][1:a:0]concat=n={0}:v=1:a=1[outv][outa]".format(count),
'-map',
"[outv]",
'-map',
"[outa]",
"output.mp4"]
print(f'the command list prints out as {commandList}')
subprocess.run(commandList)
收到错误(字符串是否传递为str(s)
,或按照显示的格式...
Unrecognized option 'i movie1.mp4 -i movie2.mp4 -i credits.mp4'.
Error splitting the argument list: Option not found
这是输入字符串的打印输出
-i movie1.mp4 -i movie2.mp4 -i credits.mp4
这是命令列表的打印输出
['ffmpeg', '-hide_banner', '-loglevel', 'error', '-i movie1.mp4 -i movie2.mp4 -i credits.mp4', '-filter_complex', '[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=3:v=1:a=1[outv][outa]', '-map', '[outv]', '-map', '[outa]', 'output.mp4']