opencv - video looks good but frames are rotated 90 degrees

前端 未结 2 856
独厮守ぢ
独厮守ぢ 2020-12-19 13:13

We save a video on a mobile client and send it to a server. On the server, I use the following code to save the frames:>

import skvideo.io
import cv2

haar =         


        
2条回答
  •  感情败类
    2020-12-19 13:52

    It looks like OpenCV does not record the rotation metadata of the video file with VideoCapture() as you can see by the propIds that it stores.

    I'm not sure if scikit-video does. It looks like they have a metadata puller called ffprobe which might be able to pull the rotation. See here for an example of how to call and see the output. This shows a hefty list of metadata---no rotation---but that might just be because it's not set or of a movie type which doesn't have rotation metadata.

    Another way to grab it would be to read the metadata directly from ffmpeg. I found an old StackOverflow answer that wrote a little python code to extract specifically the rotation metadata from a video using ffmpeg.

提交回复
热议问题