从ffpmeg获取视频分辨率

时间:2018-05-21 22:36:17

标签: python regex ffmpeg subprocess

我尝试解析视频文件,并希望此代码有助于感谢来自arionikGitHub

from subprocess import Popen, PIPE

def getWH(pathvideofile):
in_pipe = Popen(["ffmpeg", "-i", "\"%s\"" % (pathvideofile)], stderr=PIPE)
lines = in_pipe.stderr.readlines()
for line in lines:
    rx = re.compile('.+Video.+, (\d{2,4})x(\d{2,4}).+')
    m = rx.match(line)
    if m is not None:
        w = int(m.group(1))
        h = int(m.group(2))
return w, h

但是得到这个错误代码:

m = rx.match(line)
TypeError: cannot use a string pattern on a bytes-like object

它可能是什么?

谢谢,

0 个答案:

没有答案