我在传递参数时遇到以下错误。有人能帮我找出这个问题吗?我在终端中向我的功能传递指令,如下所示:
python makeQuicktime.py -i /Volumes/P003A/TM_Cloud/Nagrania/Karta_04/XDROOT/Clip/D004C010_141026MM.MXF -f 25 -c prores
这是main函数——正如您所看到的,我试图将参数——编解码器传递为字符串:
if __name__ == "__main__":
args = docopt(__doc__, version='makeQuicktime 0.0.1')
print args
cmd_args = ""
codec=str(args['--codec'])
makeQuicktime( args['--input'], fps=args['--fps'], codec=str(args['--codec']) )
os._exit(0)
该代码正在运行的其他函数的部分(makeProRes,第110行是输出变量):
subprocess.call([FFMPEG_PATH, 'i', input,
'-start_number', start_frame, '-r', fps,
'-c:v', 'prores',
'-profile:v', '2',
'-c:a', 'copy',
'-threads', cpus,
output
])
错误:
Traceback (most recent call last):
File "makeQuicktime.py", line 123, in <module>
makeQuicktime( args['--input'], fps=args['--fps'], codec=str(args['--codec']) )
File "makeQuicktime.py", line 53, in makeQuicktime
makeProRes(1, input, fps, output)
File "makeQuicktime.py", line 110, in makeProRes
output
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings
start_frame
、fps
或cpus
中的一个是数字,而不是字符串。找到后,将其封装在str()
中进行转换。