我有来自ffmpeg
示例的以下代码,该代码工作正常,并将查询的输出返回到输出中:
def get_trim(input):
def _logged_popen(cmd_line, *args, **kwargs):
return subprocess.Popen(cmd_line, *args, **kwargs)
p = _logged_popen(
(ffmpeg
.input(input)
.filter('silencedetect', noise='0.001')
.output('-', format='null')
.compile()
),
stderr=subprocess.PIPE
)
output = p.communicate()[1].decode('utf-8')
然而,我想把它重构成适合我自己需要和风格的东西。我想删除_logged_popen
当我尝试用以下方法执行此操作时:
def get_trim(input):
cmd = ffmpeg.input(input).filter('silencedetect', noise='0.001').output('-', format='null').compile()
p = subprocess.Popen(cmd, stderr=subprocess.PIPE)
这根本不起作用。所以我检查了cmd
的内容,它产生了这个数组:
['ffmpeg', '-i', <built-in function input>, '-filter_complex', '[0]silencedetect=noise=0.001[s0]', '-map', '[s0]', '-f', 'null', '-']
当通过第一个代码路径时,代码将按预期执行,但在第二个代码路径中,它将与参数中的数组cmd
一起执行,这是怎么回事
在第一个代码路径中满足Popen
而在第二个代码路径中不满足Popen
的代码中发生了什么过程
部分解决
现在已知使用.input(input)存在问题,它在第一条路径中工作,但在第二条路径中不工作。不过问题还是一样
目前没有回答
相关问题 更多 >
编程相关推荐