问题
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