python - 从 ffpmeg 获取视频分辨率
问题描述
我尝试获取视频文件的分辨率,并希望此代码对来自GitHub的arionik有所帮助
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
它可能是什么?
谢谢,
解决方案
推荐阅读
- java - 来自所有线程的 Java ThreadLocal 转储值
- python - 如何在 SQLAlchemy 中正确连接数据库。获取 NameError:未定义名称“用户”
- mysql - 如何在 MySQL 中使用嵌套循环连接而不是块嵌套循环连接?
- django - 如何通过按钮单击执行特定操作
- java - 关于 javafx tableview
- php - 有没有办法让我的代码上传更快?
- javascript - 单击元素时对输入的角度关注
- javascript - 这个 for 循环中发生了什么?
- node.js - 错误:发送后无法设置标头。在nodejs中
- angular - Angular 7 http错误处理无法正常工作