如何在Python中获取视频文件的方向 [英] how to get a video file's orientation in Python

查看:463
本文介绍了如何在Python中获取视频文件的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将视频文件的帧加载到numpy数组中.我希望框架正确直立,这意味着我需要读取视频文件中的方向元数据,并相应地旋转加载的框架.

I would like to load a video file's frames into a numpy array. I want the frames to be properly upright, which means I need to read the orientation metadata in the video file, and rotate the loaded frames accordingly.

我有一种加载帧的方法(opencv的python绑定),所以我所需要的只是一种读取视频文件方向元数据的方法.

I have a means of loading the frames (opencv's python bindings), so all I need is a way to read the video file's orientation metadata.

我正在尝试读取在Ubuntu 14.04计算机上运行的python中记录在iPhone上的.MOV文件.

I'm trying to read a .MOV file recorded off my iPhone, in python running on an Ubuntu 14.04 machine.

我看过的东西:

  • opencv:无法检查视频方向
  • hach​​oir-元数据:不显示方向元数据
  • 酶:仅适用于.mkv文件AFAICT.
  • ffmpeg:在Ubuntu的存储库中不再作为独立的可执行文件提供.这是一个大问题,因为我宁愿手动指定旋转方式,也不用麻烦从源代码编译ffmpeg以获得视频方向.
  • PIL,pyexiv:AFAICT,仅加载图像文件.
  • opencv: no way of inspecting video orientation
  • hachoir-metadata: doesn't display orientation metadata
  • enzyme: only works on .mkv files, AFAICT.
  • ffmpeg: no longer available as a stand-alone executable on Ubuntu's repositories. This is a dealbreaker since I'd rather just hand-specify the rotation rather than go through the trouble of compiling ffmpeg from source just to get video orientation.
  • PIL, pyexiv: AFAICT, only loads image files.

我正在Ubuntu 14.04计算机上运行代码,因此我正在寻找该平台上可用的库或命令行程序.

I'm running the code on an Ubuntu 14.04 machine, so I'm looking for libraries or command-line programs available on that platform.

任何指针将不胜感激.

推荐答案

我们使用MediaInfo( libmediainfo )

We use MediaInfo (libmediainfo)

它同时在Windows和Ubuntu上运行,您可以获取所需的全部内容(编解码器,宽高比,fps,比特率,方向...).

it is running both on Windows and Ubuntu, and you can get all you need (codec, aspect, fps, bitrate, orientation...).

这篇关于如何在Python中获取视频文件的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆