修改probe文件 p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='gbk')
当我用cmd调用ffprobe的时候完全没问题,
但是切换subprocess.Popen就一直报错
当把源码里面加入输出字符格式
然后打印,发现真正的报错是ffprobe不是一个可运行的程序,也就是环境变量识别失败
然后我去查看环境变量,发现并没有配置错误
然后我就思考会不会是subprocess.Popen本身存在问题,
果不其然,,,,当我用subprocess.Popen答应set命令,发现环境变量没有ffprobe的
然后我重启电脑后,再次使用subprocess.Popen,就好了,打印出来了
subprocess.Popen读取的上一次用户注销前的环境变量,,,,
话说这是windows,,总之重启之后就解决了
def probe(filename, cmd='ffprobe', **kwargs):"""Run ffprobe on the specified file and return a JSON representation of the output.Raises::class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code,an :class:`Error` is returned with a generic error message.The stderr output can be retrieved by accessing the``stderr`` property of the exception."""args = [cmd, '-show_format', '-show_streams', '-of', 'json']args += convert_kwargs_to_cmd_line_args(kwargs)args += [filename]p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='gbk')print(args)out, err = p.communicate()print(out)print(p.returncode)if p.returncode != 0:raise Error(cmd, out, err)return json.loads(out.decode('utf-8'))