How to get orientation of a video file in Python

I would like to load frames of video files into a numpy array. I want the frames to be correctly vertical, which means I need to read the orientation metadata in the video file and rotate the loaded frames accordingly.

I have a way to load frames (opencv python bindings), so all I need is a way to read the orientation metadata of video files.

I am trying to read a .MOV file recorded from my iPhone in python running on an Ubuntu 14.04 machine.

Stuff I was looking at:

  • opencv: no way to check video orientation
  • hachoir-metadata: does not display targeting enzyme metadata
  • : only works with .mkv files, AFAICT.
  • ffmpeg: No longer available as a standalone executable in the Ubuntu repositories. This is a rogue, as I would rather just manually specify the rotation rather than running into the problem of compiling ffmpeg from source to get the orientation of the video.
  • PIL, pyexiv: AFAICT, only downloads image files.

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

Any pointers would be greatly appreciated.

+3


source to share


2 answers


We are using MediaInfo ( libmediainfo )



it works on both Windows and Ubuntu and you can get everything you need (codec, aspect, fps, bitrate, orientation ...).

0


source


use qtrotate. This is just one file and it works with .Mov files.



https://github.com/danielgtaylor/qtrotate

0


source







All Articles