Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

46 lines
987 B
Go

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
}