Detect Orientation of Video and auto rotate if needed

时光总嘲笑我的痴心妄想 提交于 2019-12-11 20:08:28

问题


I am looking to see if its possible to get the device orientation of a video to check and see if its needs to be rotated in PHP with ffmpeg.

Is this even possible? I have done it easy enough with images, but I have not found anything so far to help with this.


回答1:


Device orientation is a client side property, and PHP is strictly server-side. Quickly googling led me to this page, which has an example for the iPhone. The author offers this function, which is called on page load:

function updateOrientation(){  
    var contentType = "show_";  
    switch(window.orientation){  
        case 0:  
            contentType += "normal";  
            break;  

        case -90:  
            contentType += "right";  
            break;  

        case 90:  
            contentType += "left";  
            break;  

        case 180:  
            contentType += "flipped";  
            break;  
    }  
    document.getElementById("page_wrapper").setAttribute("class", contentType);  
}  

CSS is defined to handle styling for .show_normal, .show_right, .show_left and .show_flipped

.show_normal,  
.show_flipped{  
   width:320px;  
}  
.show_left,  
.show_right{  
    width:480px;  
}  

If you need the value for the orientation in PHP, you can send the value of window.orientation to a script via AJAX. There is also an event: window.onorientationchange that gets fired whenever the orientation changes. I believe both of those properties on the window are available for both iPhone and Android devices.




回答2:


exiftool -Rotation <filename>


来源:https://stackoverflow.com/questions/11000107/detect-orientation-of-video-and-auto-rotate-if-needed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!