Search code examples
iphoneopencvexif

OpenCV detect iphone orientation


I have a site where users can upload video. When testing some video uploads that are processed with OpenCV and Python, if the video was recorded on an iPhone it always assumes the video was taken in landscape mode by rotating the phone 90 degrees to the left, such that videos in portrait mode are sideways and videos taken in the other landscape direction (90 degrees to the right) are upside down.

I know I can use OpenCV to rotate videos, but is there a way to detect: a) if the video is even taken with an iPhone or not b) if so, what the orientation should be, how much to rotate the video by


Solution

  • OpenCV is an computer vision library, for your problem you can't use OpenCV (AFAIK). What you need is to get the metadata of the video. Metadata contains the all the information you need about that video. Here you can see what does metadata contains. You should search how to extract metadata from a video. Take a look at this.

    Good luck!