您必须拆分选项:
command = [ffm_path, '-i', ffm_input, '-r', ffm_rate, '-f', ffm_format, '-vframes', ffm_nb_frames, ffm_filename]
The ffm_input
, ffm_rate
, ffm_format
应该只包含值:
ffm_input = self.path
ffm_rate = '5'
ffm_nd_frames = str(nb_frames)
ffm_format = 'v412' if platform.system() == 'Linux' else 'image2'
当您传递列表时,不会进行任何解析-r 5
被视为单个参数,但程序希望您提供两个单独的参数-r
其次是5
.
基本上,如果您将它们作为列表中的单个元素,就好像您在命令行上引用它们一样:
$ echo "-n hello"
-n hello
$ echo -n hello
hello$
在第一个例子中echo
看到一个参数-n hello
。由于它与任何选项都不匹配,因此只打印它。在第二种情况下echo
看到两个参数-n
and hello
,第一个是抑制行尾的有效选项,正如您所看到的,提示是在之后打印的hello
而不是在自己的线路上。