我尝试解析视频文件,并希望此代码有助于感谢来自arionik的GitHub
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
它可能是什么?
谢谢,