@@ -0,0 +1,45 @@
|
||||
package common
|
||||
|
||||
import "math"
|
||||
|
||||
type Quality string
|
||||
type Direction string
|
||||
|
||||
const (
|
||||
High Quality = "high" //影片质量高 720P以上
|
||||
Middle Quality = "middle" //影片质量高 480P-720P以上
|
||||
Low Quality = "low" //影片质量高 480P以下
|
||||
|
||||
Vertical Direction = "vertical" //竖屏
|
||||
Horizontal Direction = "horizontal" //横屏
|
||||
Square Direction = "square" //方形屏
|
||||
)
|
||||
|
||||
type IdentifiInfo struct {
|
||||
Quality Quality
|
||||
Direction Direction
|
||||
}
|
||||
|
||||
// 提取视频信息
|
||||
func IdentifiVideoInfo(width, height int64) (info IdentifiInfo) {
|
||||
//竖屏
|
||||
if height > width {
|
||||
info.Direction = Vertical
|
||||
}
|
||||
if height == width {
|
||||
info.Direction = Square
|
||||
}
|
||||
if height < width {
|
||||
info.Direction = Horizontal
|
||||
}
|
||||
max := math.Max(float64(width), float64(height))
|
||||
min := math.Min(float64(width), float64(height))
|
||||
if min >= 720 && max >= 1280 {
|
||||
info.Quality = High
|
||||
} else if min >= 480 && max >= 800 {
|
||||
info.Quality = Middle
|
||||
} else {
|
||||
info.Quality = Low
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user