问题描述
我们将视频保存在移动客户端上,并将其发送到服务器.在服务器上,我使用以下代码保存框架:>
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 =
'/home/ubuntu/opencv/data/haarcascades/haarcascade_frontalface_alt.xml'
face_cascade = cv2.CascadeClassifier(haar)
ret = True
video = 'my_video.mov'
i = 0
while ret == True:
cap = skvideo.io.VideoCapture(video)
ret, frame = cap.read()
cv2.imwrite('frame_'+str(i)+'.jpg',frame)
i+=1
当我们在Windows Media Player或iTunes上播放视频时,它看起来不错. IE.玩家知道如何定向.
When we play the video on a windows media player or itunes, it looks good. I.e. the player knows how to orient it.
但是skvideo.io不知道,我们保存的那些帧会逆时针旋转90度.
But skvideo.io does not know that, and those frames we saved are rotated 90 degrees counterclockwise.
我们如何将信息嵌入到skvideo知道正确方向的视频文件(.mov)文件中?
推荐答案
skvideo中有一个小故障,它没有读取可用的元数据.对于移动拍摄的视频,其旋转,但是元数据包含此类参数. skvideo团队已提交修复程序,当前skvideo版本1.1.7会从移动设备读取元数据,这表明应该对视频进行分级.然后skvideo.io.vread旋转文件:
there was a glitch in skvideo, it was not reading the available metadata. For videos taken in mobile are rotated, but metadata includes such parameter. The skvideo team committed a fix, and current skvideo version 1.1.7 reads metadata from mobile, that indicates that video should be rorated. skvideo.io.vread then rotates the file:
1)使用较新的skvideo版本1.1.7,可以在 https:上克隆: //github.com/scikit-video/scikit-video
1) use newer skvideo version, 1.1.7 which can be cloned at https://github.com/scikit-video/scikit-video
2)您可以使用以下代码读取视频中的所有帧,最有可能读取元数据
import skvideo.io
videogen = skvideo.io.vread(f.name)
如果以人像模式拍摄,视频将自动旋转.
That will rotate the video automatically if it was taken in portrait mode.
3)在skvideo存储库上创建了一个问题,请查看以供进一步参考: https://github.com/scikit-video/scikit-video/issues/40
3) Created an issue on skvideo repo, take a look for further reference: https://github.com/scikit-video/scikit-video/issues/40
这篇关于opencv-视频看起来不错,但是帧旋转了90度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!