Compare commits

...

4 Commits

Author SHA1 Message Date
骑着蜗牛追导弹 8be509d694 upd:改版 2024-07-16 19:12:39 +08:00
骑着蜗牛追导弹 953c3ad067 upd:改版 2024-07-16 19:11:35 +08:00
骑着蜗牛追导弹 6400903610 upd:改版 2024-07-16 19:10:40 +08:00
骑着蜗牛追导弹 fcc42041ca upd:v2.0 2024-05-13 16:39:27 +08:00
3 changed files with 230 additions and 170 deletions

Binary file not shown.

View File

@ -28,6 +28,7 @@ var supportImageTypes = []string{
// 水平图片 // 水平图片
var normalImageList []string var normalImageList []string
var horizontalUnHandleImageList []string
var horizontalGifImageList []string var horizontalGifImageList []string
var horizontal2KImageList []string var horizontal2KImageList []string
var horizontal1KImageList []string var horizontal1KImageList []string
@ -43,11 +44,14 @@ var horizontalHKImageList []string
// 标准横向图片 // 标准横向图片
var horizontalStandard720PImageList []string var horizontalStandard720PImageList []string
var horizontalStandard1080PImageList []string var horizontalStandard1080PImageList []string
var horizontalStandard2KImageList []string
var horizontalStandard4KImageList []string var horizontalStandard4KImageList []string
var horizontalStandard5KImageList []string
var horizontalStandard8KImageList []string var horizontalStandard8KImageList []string
// 垂直图片 // 垂直图片
var verticalGifImageList []string var verticalGifImageList []string
var verticalUnHandleImageList []string
var vertical1KImageList []string var vertical1KImageList []string
var vertical2KImageList []string var vertical2KImageList []string
var vertical3KImageList []string var vertical3KImageList []string
@ -60,6 +64,7 @@ var vertical9KImageList []string
var verticalHKImageList []string var verticalHKImageList []string
// 等比图片 // 等比图片
var squareUnHandleImageList []string
var squareGifImageList []string var squareGifImageList []string
var square1KImageList []string var square1KImageList []string
var square2KImageList []string var square2KImageList []string
@ -71,13 +76,6 @@ var square7KImageList []string
var square8KImageList []string var square8KImageList []string
var square9KImageList []string var square9KImageList []string
var squareHKImageList []string var squareHKImageList []string
// 标准等比图片
var squareStandard720PImageList []string
var squareStandard1080PImageList []string
var squareStandard4KImageList []string
var squareStandard8KImageList []string
var psdImageList []string var psdImageList []string
func DoHandleImage(rootDir string) { func DoHandleImage(rootDir string) {
@ -173,7 +171,7 @@ func doPickImageFile(uid string, rootDir string, imagePath2WidthHeightMap map[st
handleVerticalImage(currentImagePath, height, suffix) handleVerticalImage(currentImagePath, height, suffix)
continue continue
} }
handleSquareImage(currentImagePath, width, height, suffix) handleSquareImage(currentImagePath, width, suffix)
} }
moveNormalImage(rootDir, uid) moveNormalImage(rootDir, uid)
moveHorizontalImage(rootDir, uid) moveHorizontalImage(rootDir, uid)
@ -183,6 +181,7 @@ func doPickImageFile(uid string, rootDir string, imagePath2WidthHeightMap map[st
func moveSquareImage(rootDir string, uid string) { func moveSquareImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator) pathSeparator := string(os.PathSeparator)
squareUnHandleImagePath := rootDir + pathSeparator + uid + "_图片_等比_未处理"
squareGifImagePath := rootDir + pathSeparator + uid + "_图片_等比_GIF" squareGifImagePath := rootDir + pathSeparator + uid + "_图片_等比_GIF"
square1KImagePath := rootDir + pathSeparator + uid + "_图片_等比_1k" square1KImagePath := rootDir + pathSeparator + uid + "_图片_等比_1k"
square2KImagePath := rootDir + pathSeparator + uid + "_图片_等比_2k" square2KImagePath := rootDir + pathSeparator + uid + "_图片_等比_2k"
@ -194,6 +193,10 @@ func moveSquareImage(rootDir string, uid string) {
square8KImagePath := rootDir + pathSeparator + uid + "_图片_等比_8k" square8KImagePath := rootDir + pathSeparator + uid + "_图片_等比_8k"
square9KImagePath := rootDir + pathSeparator + uid + "_图片_等比_9k" square9KImagePath := rootDir + pathSeparator + uid + "_图片_等比_9k"
squareHKImagePath := rootDir + pathSeparator + uid + "_图片_等比_原图" squareHKImagePath := rootDir + pathSeparator + uid + "_图片_等比_原图"
if len(squareUnHandleImageList) > 0 {
util.CreateDir(squareUnHandleImagePath)
doMoveFileToDir(squareUnHandleImageList, squareUnHandleImagePath)
}
if len(squareGifImageList) > 0 { if len(squareGifImageList) > 0 {
util.CreateDir(squareGifImagePath) util.CreateDir(squareGifImagePath)
doMoveFileToDir(squareGifImageList, squareGifImagePath) doMoveFileToDir(squareGifImageList, squareGifImagePath)
@ -240,53 +243,36 @@ func moveSquareImage(rootDir string, uid string) {
} }
} }
func handleSquareImage(currentImagePath string, width int, height int, suffix string) { func handleSquareImage(currentImagePath string, width int, suffix string) {
if strings.EqualFold(suffix, ".gif") { if strings.EqualFold(suffix, ".gif") {
squareGifImageList = append(squareGifImageList, currentImagePath) squareGifImageList = append(squareGifImageList, currentImagePath)
return return
} }
if width < 1000 { if width < caleHorizontalPix(1) {
normalImageList = append(normalImageList, currentImagePath) normalImageList = append(normalImageList, currentImagePath)
} else if width >= 1000 && width < 2000 { } else if width >= caleHorizontalPix(1) && width < caleHorizontalPix(2) {
// 1280 x 720 -> 720p
if width == 1280 && height == 720 {
squareStandard720PImageList = append(squareStandard720PImageList, currentImagePath)
return
}
// 1920 x 1080 -> 1080p
if width == 1920 && height == 1080 {
squareStandard1080PImageList = append(squareStandard1080PImageList, currentImagePath)
return
}
square1KImageList = append(square1KImageList, currentImagePath) square1KImageList = append(square1KImageList, currentImagePath)
} else if width >= 2000 && width < 3000 { } else if width >= caleHorizontalPix(2) && width < caleHorizontalPix(3) {
square2KImageList = append(square2KImageList, currentImagePath) square2KImageList = append(square2KImageList, currentImagePath)
} else if width >= 3000 && width < 4000 { } else if width >= caleHorizontalPix(3) && width < caleHorizontalPix(4) {
// 3840 x 2160 -> 4k
if width == 3840 && height == 2160 {
squareStandard4KImageList = append(squareStandard4KImageList, currentImagePath)
return
}
square3KImageList = append(square3KImageList, currentImagePath) square3KImageList = append(square3KImageList, currentImagePath)
} else if width >= 4000 && width < 5000 { } else if width >= caleHorizontalPix(4) && width < caleHorizontalPix(5) {
square4KImageList = append(square4KImageList, currentImagePath) square4KImageList = append(square4KImageList, currentImagePath)
} else if width >= 5000 && width < 6000 { } else if width >= caleHorizontalPix(5) && width < caleHorizontalPix(6) {
square5KImageList = append(square5KImageList, currentImagePath) square5KImageList = append(square5KImageList, currentImagePath)
} else if width >= 6000 && width < 7000 { } else if width >= caleHorizontalPix(6) && width < caleHorizontalPix(7) {
square6KImageList = append(square6KImageList, currentImagePath) square6KImageList = append(square6KImageList, currentImagePath)
} else if width >= 7000 && width < 8000 { } else if width >= caleHorizontalPix(7) && width < caleHorizontalPix(8) {
// 7680 x 4320 -> 8k
if width == 7680 && height == 4320 {
squareStandard8KImageList = append(squareStandard8KImageList, currentImagePath)
return
}
square7KImageList = append(square7KImageList, currentImagePath) square7KImageList = append(square7KImageList, currentImagePath)
} else if width >= 8000 && width < 9000 { } else if width >= caleHorizontalPix(8) && width < caleHorizontalPix(9) {
square8KImageList = append(square8KImageList, currentImagePath) square8KImageList = append(square8KImageList, currentImagePath)
} else if width >= 9000 && width < 10000 { } else if width >= caleHorizontalPix(9) && width < caleHorizontalPix(10) {
square9KImageList = append(square9KImageList, currentImagePath) square9KImageList = append(square9KImageList, currentImagePath)
} else if width >= 10000 { } else if width >= caleHorizontalPix(10) {
squareHKImageList = append(squareHKImageList, currentImagePath) squareHKImageList = append(squareHKImageList, currentImagePath)
} else {
// 未处理的等比图片
squareUnHandleImageList = append(squareUnHandleImageList, currentImagePath)
} }
} }
@ -294,6 +280,7 @@ func handleSquareImage(currentImagePath string, width int, height int, suffix st
func moveVerticalImage(rootDir string, uid string) { func moveVerticalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator) pathSeparator := string(os.PathSeparator)
verticalGifImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_GIF" verticalGifImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_GIF"
verticalUnHandleImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_未处理"
vertical1KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_1k" vertical1KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_1k"
vertical2KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_2k" vertical2KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_2k"
vertical3KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_3k" vertical3KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_3k"
@ -308,6 +295,10 @@ func moveVerticalImage(rootDir string, uid string) {
util.CreateDir(verticalGifImagePath) util.CreateDir(verticalGifImagePath)
doMoveFileToDir(verticalGifImageList, verticalGifImagePath) doMoveFileToDir(verticalGifImageList, verticalGifImagePath)
} }
if len(verticalUnHandleImageList) > 0 {
util.CreateDir(verticalUnHandleImagePath)
doMoveFileToDir(verticalUnHandleImageList, verticalUnHandleImagePath)
}
if len(vertical1KImageList) > 0 { if len(vertical1KImageList) > 0 {
util.CreateDir(vertical1KImagePath) util.CreateDir(vertical1KImagePath)
doMoveFileToDir(vertical1KImageList, vertical1KImagePath) doMoveFileToDir(vertical1KImageList, vertical1KImagePath)
@ -353,6 +344,7 @@ func moveVerticalImage(rootDir string, uid string) {
// 移动水平图片 // 移动水平图片
func moveHorizontalImage(rootDir string, uid string) { func moveHorizontalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator) pathSeparator := string(os.PathSeparator)
horizontalUnHandleImagePath := rootDir + pathSeparator + uid + "_图片_横屏_未处理"
horizontalGifImagePath := rootDir + pathSeparator + uid + "_图片_横屏_GIF" horizontalGifImagePath := rootDir + pathSeparator + uid + "_图片_横屏_GIF"
horizontal1KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_1k" horizontal1KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_1k"
horizontal2KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_2k" horizontal2KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_2k"
@ -366,8 +358,14 @@ func moveHorizontalImage(rootDir string, uid string) {
horizontalHKImagePath := rootDir + pathSeparator + uid + "_图片_横屏_原图" horizontalHKImagePath := rootDir + pathSeparator + uid + "_图片_横屏_原图"
horizontalStandard720PImagePath := rootDir + pathSeparator + uid + "_图片_横屏_720P" horizontalStandard720PImagePath := rootDir + pathSeparator + uid + "_图片_横屏_720P"
horizontalStandard1080PImagePath := rootDir + pathSeparator + uid + "_图片_横屏_1080P" horizontalStandard1080PImagePath := rootDir + pathSeparator + uid + "_图片_横屏_1080P"
horizontalStandard2KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_2KP"
horizontalStandard4KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_4KP" horizontalStandard4KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_4KP"
horizontalStandard5KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_5KP"
horizontalStandard8KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_8KP" horizontalStandard8KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_8KP"
if len(horizontalUnHandleImageList) > 0 {
util.CreateDir(horizontalUnHandleImagePath)
doMoveFileToDir(horizontalUnHandleImageList, horizontalUnHandleImagePath)
}
if len(horizontalGifImageList) > 0 { if len(horizontalGifImageList) > 0 {
util.CreateDir(horizontalGifImagePath) util.CreateDir(horizontalGifImagePath)
doMoveFileToDir(horizontalGifImageList, horizontalGifImagePath) doMoveFileToDir(horizontalGifImageList, horizontalGifImagePath)
@ -420,10 +418,18 @@ func moveHorizontalImage(rootDir string, uid string) {
util.CreateDir(horizontalStandard1080PImagePath) util.CreateDir(horizontalStandard1080PImagePath)
doMoveFileToDir(horizontalStandard1080PImageList, horizontalStandard1080PImagePath) doMoveFileToDir(horizontalStandard1080PImageList, horizontalStandard1080PImagePath)
} }
if len(horizontalStandard2KImageList) > 0 {
util.CreateDir(horizontalStandard2KImagePath)
doMoveFileToDir(horizontalStandard2KImageList, horizontalStandard2KImagePath)
}
if len(horizontalStandard4KImageList) > 0 { if len(horizontalStandard4KImageList) > 0 {
util.CreateDir(horizontalStandard4KImagePath) util.CreateDir(horizontalStandard4KImagePath)
doMoveFileToDir(horizontalStandard4KImageList, horizontalStandard4KImagePath) doMoveFileToDir(horizontalStandard4KImageList, horizontalStandard4KImagePath)
} }
if len(horizontalStandard5KImageList) > 0 {
util.CreateDir(horizontalStandard5KImagePath)
doMoveFileToDir(horizontalStandard5KImageList, horizontalStandard5KImagePath)
}
if len(horizontalStandard8KImageList) > 0 { if len(horizontalStandard8KImageList) > 0 {
util.CreateDir(horizontalStandard8KImagePath) util.CreateDir(horizontalStandard8KImagePath)
doMoveFileToDir(horizontalStandard8KImageList, horizontalStandard8KImagePath) doMoveFileToDir(horizontalStandard8KImageList, horizontalStandard8KImagePath)
@ -446,28 +452,31 @@ func handleVerticalImage(currentImagePath string, height int, suffix string) {
verticalGifImageList = append(verticalGifImageList, currentImagePath) verticalGifImageList = append(verticalGifImageList, currentImagePath)
return return
} }
if height < 1000 { if height < caleVerticalPix(1) {
normalImageList = append(normalImageList, currentImagePath) normalImageList = append(normalImageList, currentImagePath)
} else if height >= 1000 && height < 2000 { } else if height >= caleVerticalPix(1) && height < caleVerticalPix(2) {
vertical1KImageList = append(vertical1KImageList, currentImagePath) vertical1KImageList = append(vertical1KImageList, currentImagePath)
} else if height >= 2000 && height < 3000 { } else if height >= caleVerticalPix(2) && height < caleVerticalPix(3) {
vertical2KImageList = append(vertical2KImageList, currentImagePath) vertical2KImageList = append(vertical2KImageList, currentImagePath)
} else if height >= 3000 && height < 4000 { } else if height >= caleVerticalPix(3) && height < caleVerticalPix(4) {
vertical3KImageList = append(vertical3KImageList, currentImagePath) vertical3KImageList = append(vertical3KImageList, currentImagePath)
} else if height >= 4000 && height < 5000 { } else if height >= caleVerticalPix(4) && height < caleVerticalPix(5) {
vertical4KImageList = append(vertical4KImageList, currentImagePath) vertical4KImageList = append(vertical4KImageList, currentImagePath)
} else if height >= 5000 && height < 6000 { } else if height >= caleVerticalPix(5) && height < caleVerticalPix(6) {
vertical5KImageList = append(vertical5KImageList, currentImagePath) vertical5KImageList = append(vertical5KImageList, currentImagePath)
} else if height >= 6000 && height < 7000 { } else if height >= caleVerticalPix(6) && height < caleVerticalPix(7) {
vertical6KImageList = append(vertical6KImageList, currentImagePath) vertical6KImageList = append(vertical6KImageList, currentImagePath)
} else if height >= 7000 && height < 8000 { } else if height >= caleVerticalPix(7) && height < caleVerticalPix(8) {
vertical7KImageList = append(vertical7KImageList, currentImagePath) vertical7KImageList = append(vertical7KImageList, currentImagePath)
} else if height >= 8000 && height < 9000 { } else if height >= caleVerticalPix(8) && height < caleVerticalPix(9) {
vertical8KImageList = append(vertical8KImageList, currentImagePath) vertical8KImageList = append(vertical8KImageList, currentImagePath)
} else if height >= 9000 && height < 10000 { } else if height >= caleVerticalPix(9) && height < caleVerticalPix(10) {
vertical9KImageList = append(vertical9KImageList, currentImagePath) vertical9KImageList = append(vertical9KImageList, currentImagePath)
} else if height >= 10000 { } else if height >= caleVerticalPix(10) {
verticalHKImageList = append(verticalHKImageList, currentImagePath) verticalHKImageList = append(verticalHKImageList, currentImagePath)
} else {
// 未处理的垂直图片
verticalUnHandleImageList = append(verticalUnHandleImageList, currentImagePath)
} }
} }
@ -477,9 +486,9 @@ func handleHorizontalImage(currentImagePath string, width int, height int, suffi
horizontalGifImageList = append(horizontalGifImageList, currentImagePath) horizontalGifImageList = append(horizontalGifImageList, currentImagePath)
return return
} }
if width < 1000 { if width < caleHorizontalPix(1) {
normalImageList = append(normalImageList, currentImagePath) normalImageList = append(normalImageList, currentImagePath)
} else if width >= 1000 && width < 2000 { } else if width >= caleHorizontalPix(1) && width < caleHorizontalPix(2) {
// 1280 x 720 -> 720p // 1280 x 720 -> 720p
if width == 1280 && height == 720 { if width == 1280 && height == 720 {
horizontalStandard720PImageList = append(horizontalStandard720PImageList, currentImagePath) horizontalStandard720PImageList = append(horizontalStandard720PImageList, currentImagePath)
@ -491,34 +500,47 @@ func handleHorizontalImage(currentImagePath string, width int, height int, suffi
return return
} }
horizontal1KImageList = append(horizontal1KImageList, currentImagePath) horizontal1KImageList = append(horizontal1KImageList, currentImagePath)
} else if width >= 2000 && width < 3000 { } else if width >= caleHorizontalPix(2) && width < caleHorizontalPix(3) {
// 2560 x 1440 -> 2k
if width == 2560 && height == 1440 {
horizontalStandard2KImageList = append(horizontalStandard2KImageList, currentImagePath)
return
}
horizontal2KImageList = append(horizontal2KImageList, currentImagePath) horizontal2KImageList = append(horizontal2KImageList, currentImagePath)
} else if width >= 3000 && width < 4000 { } else if width >= caleHorizontalPix(3) && width < caleHorizontalPix(4) {
// 3840 x 2160 -> 4k // 3840 x 2160 -> 4k
if width == 3840 && height == 2160 { if width == 3840 && height == 2160 {
horizontalStandard4KImageList = append(horizontalStandard4KImageList, currentImagePath) horizontalStandard4KImageList = append(horizontalStandard4KImageList, currentImagePath)
return return
} }
horizontal3KImageList = append(horizontal3KImageList, currentImagePath) horizontal3KImageList = append(horizontal3KImageList, currentImagePath)
} else if width >= 4000 && width < 5000 { } else if width >= caleHorizontalPix(4) && width < caleHorizontalPix(5) {
horizontal4KImageList = append(horizontal4KImageList, currentImagePath) horizontal4KImageList = append(horizontal4KImageList, currentImagePath)
} else if width >= 5000 && width < 6000 { } else if width >= caleHorizontalPix(5) && width < caleHorizontalPix(6) {
// 5120 x 2880 -> 5k
if width == 5120 && height == 2880 {
horizontalStandard5KImageList = append(horizontalStandard5KImageList, currentImagePath)
return
}
horizontal5KImageList = append(horizontal5KImageList, currentImagePath) horizontal5KImageList = append(horizontal5KImageList, currentImagePath)
} else if width >= 6000 && width < 7000 { } else if width >= caleHorizontalPix(6) && width < caleHorizontalPix(7) {
horizontal6KImageList = append(horizontal6KImageList, currentImagePath) horizontal6KImageList = append(horizontal6KImageList, currentImagePath)
} else if width >= 7000 && width < 8000 { } else if width >= caleHorizontalPix(7) && width < caleHorizontalPix(8) {
// 7680 x 4320 -> 8k // 7680 x 4320 -> 8k
if width == 7680 && height == 4320 { if width == 7680 && height == 4320 {
horizontalStandard8KImageList = append(horizontalStandard8KImageList, currentImagePath) horizontalStandard8KImageList = append(horizontalStandard8KImageList, currentImagePath)
return return
} }
horizontal7KImageList = append(horizontal7KImageList, currentImagePath) horizontal7KImageList = append(horizontal7KImageList, currentImagePath)
} else if width >= 8000 && width < 9000 { } else if width >= caleHorizontalPix(8) && width < caleHorizontalPix(9) {
horizontal8KImageList = append(horizontal8KImageList, currentImagePath) horizontal8KImageList = append(horizontal8KImageList, currentImagePath)
} else if width >= 9000 && width < 10000 { } else if width >= caleHorizontalPix(9) && width < caleHorizontalPix(10) {
horizontal9KImageList = append(horizontal9KImageList, currentImagePath) horizontal9KImageList = append(horizontal9KImageList, currentImagePath)
} else if width >= 10000 { } else if width >= caleHorizontalPix(10) {
horizontalHKImageList = append(horizontalHKImageList, currentImagePath) horizontalHKImageList = append(horizontalHKImageList, currentImagePath)
} else {
// 未分类的横向图片
horizontalUnHandleImageList = append(horizontalUnHandleImageList, currentImagePath)
} }
} }

View File

@ -10,6 +10,7 @@ import (
"math" "math"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -18,7 +19,7 @@ import (
//go:embed files/ffprobe.exe //go:embed files/ffprobe.exe
var ffprobeWin64 []byte var ffprobeWin64 []byte
var videoTag = "[PickVideo]" // 标记文件已经被整理过 var videoTag = "_[PickVideo]" // 标记文件已经被整理过
var ignoreVideoPathList []string // 忽略的文件路径 var ignoreVideoPathList []string // 忽略的文件路径
var readErrorVideoPathList []string // 读取信息异常的路径 var readErrorVideoPathList []string // 读取信息异常的路径
var videoPath2WidthHeightMap = make(map[string]string) // 视频路径和宽高比 var videoPath2WidthHeightMap = make(map[string]string) // 视频路径和宽高比
@ -44,7 +45,9 @@ var supportVideoTypes = []string{
// 水平视频 // 水平视频
var horizontalNormalVideoList []string var horizontalNormalVideoList []string
var horizontalUnHandleVideoList []string
var horizontalGifVideoList []string var horizontalGifVideoList []string
var horizontal1KVideoList []string var horizontal1KVideoList []string
var horizontal2KVideoList []string var horizontal2KVideoList []string
var horizontal3KVideoList []string var horizontal3KVideoList []string
@ -59,7 +62,9 @@ var horizontalHKVideoList []string
// 标准横向视频 // 标准横向视频
var horizontalStandard720PVideoList []string var horizontalStandard720PVideoList []string
var horizontalStandard1080PVideoList []string var horizontalStandard1080PVideoList []string
var horizontalStandard2KVideoList []string
var horizontalStandard4KVideoList []string var horizontalStandard4KVideoList []string
var horizontalStandard5KVideoList []string
var horizontalStandard8KVideoList []string var horizontalStandard8KVideoList []string
// 垂直视频 // 垂直视频
@ -75,6 +80,7 @@ var vertical7KVideoList []string
var vertical8KVideoList []string var vertical8KVideoList []string
var vertical9KVideoList []string var vertical9KVideoList []string
var verticalHKVideoList []string var verticalHKVideoList []string
var verticalUnHandleVideoList []string
// 等比视频 // 等比视频
var squareNormalVideoList []string var squareNormalVideoList []string
@ -89,10 +95,7 @@ var square7KVideoList []string
var square8KVideoList []string var square8KVideoList []string
var square9KVideoList []string var square9KVideoList []string
var squareHKVideoList []string var squareHKVideoList []string
var squareStandard720PVideoList []string var squareUnHandleVideoList []string
var squareStandard1080PVideoList []string
var squareStandard4KVideoList []string
var squareStandard8KVideoList []string
func DoHandleVideo(rootDir string) { func DoHandleVideo(rootDir string) {
// 释放ffprobe // 释放ffprobe
@ -121,7 +124,7 @@ func DoHandleVideo(rootDir string) {
fmt.Printf("=== Video总数: %d, 已读取Info: %d, 成功数: %d, 失败数: %d \n", total, successCount+errorCount+ignoreCount, successCount, errorCount) fmt.Printf("=== Video总数: %d, 已读取Info: %d, 成功数: %d, 失败数: %d \n", total, successCount+errorCount+ignoreCount, successCount, errorCount)
duration := readVideoDuration(videoFilePath) duration := readVideoDuration(videoFilePath)
if duration == 0 { if duration == 0 {
videoPath2DurationMap[videoFilePath] = "0H0M0S" videoPath2DurationMap[videoFilePath] = "00-00-00"
} else { } else {
videoPath2DurationMap[videoFilePath] = util.SecondsToHms(duration) videoPath2DurationMap[videoFilePath] = util.SecondsToHms(duration)
} }
@ -304,40 +307,49 @@ func moveVerticalVideo(rootDir string) {
if len(verticalHKVideoList) > 0 { if len(verticalHKVideoList) > 0 {
renameFileV2("[V][原]", verticalHKVideoList) renameFileV2("[V][原]", verticalHKVideoList)
} }
if len(verticalUnHandleVideoList) > 0 {
renameFileV2("[V][UnHandle]", verticalUnHandleVideoList)
}
} }
// 移动文件到根目录 // 移动文件到根目录
func renameFile(rootDir string, modelType string, videoList []string, pathSeparator string) { //func renameFile(rootDir string, modelType string, videoList []string, pathSeparator string) {
total := len(videoList) // total := len(videoList)
var count = 0 // var count = 0
bar := goPrint.NewBar(100) // bar := goPrint.NewBar(100)
bar.SetNotice("=== 重命名文件:") // bar.SetNotice("=== 重命名文件:")
bar.SetGraph(">") // bar.SetGraph(">")
for _, videoFilePath := range videoList { // for _, videoFilePath := range videoList {
wh := videoPath2WidthHeightTagMap[videoFilePath] // wh := videoPath2WidthHeightTagMap[videoFilePath]
fileName := vars.GlobalFilePath2FileNameMap[videoFilePath] // fileName := vars.GlobalFilePath2FileNameMap[videoFilePath]
if strings.Contains(fileName, videoTag) { // 处理过了 // if strings.Contains(fileName, videoTag) { // 处理过了
fileNames := strings.Split(fileName, videoTag) // fileNames := strings.Split(fileName, videoTag)
if len(fileNames) == 2 { // if len(fileNames) == 2 {
fileName = fileNames[1] // fileName = fileNames[0]
targetFilePath := rootDir + pathSeparator + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + fileName // split := strings.Split(fileName, pathSeparator)
err := os.Rename(videoFilePath, targetFilePath) // if len(split) > 0 {
if err != nil { // realFileName := split[len(split)-1]
fmt.Printf("=== 重命名异常: %s \n", videoFilePath) // //targetFilePath := rootDir + pathSeparator + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + fileName
} // targetFilePath := rootDir + pathSeparator + realFileName + videoTag + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh
} // err := os.Rename(videoFilePath, targetFilePath)
} else { // if err != nil {
targetFilePath := rootDir + pathSeparator + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + " - " + fileName // fmt.Printf("=== 重命名异常: %s \n", videoFilePath)
err := os.Rename(videoFilePath, targetFilePath) // }
if err != nil { // }
fmt.Printf("=== 重命名异常: %s \n", videoFilePath) // }
} // } else {
} // //targetFilePath := rootDir + pathSeparator + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + " - " + fileName
count = count + 1 // targetFilePath := rootDir + pathSeparator + fileName + videoTag + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh
bar.PrintBar(util.CalcPercentage(count, total)) // err := os.Rename(videoFilePath, targetFilePath)
} // if err != nil {
bar.PrintEnd("=== Finish") // fmt.Printf("=== 重命名异常: %s \n", videoFilePath)
} // }
// }
// count = count + 1
// bar.PrintBar(util.CalcPercentage(count, total))
// }
// bar.PrintEnd("=== Finish")
//}
// 移动文件到原目录 // 移动文件到原目录
func renameFileV2(modelType string, videoList []string) { func renameFileV2(modelType string, videoList []string) {
@ -350,18 +362,41 @@ func renameFileV2(modelType string, videoList []string) {
wh := videoPath2WidthHeightTagMap[videoFilePath] wh := videoPath2WidthHeightTagMap[videoFilePath]
fileName := vars.GlobalFilePath2FileNameMap[videoFilePath] fileName := vars.GlobalFilePath2FileNameMap[videoFilePath]
filePath := util.GetFileDirectory(videoFilePath) filePath := util.GetFileDirectory(videoFilePath)
if strings.Contains(fileName, videoTag) { // 处理过了 //if strings.Contains(fileName, videoTag) { // 处理过了
fileNames := strings.Split(fileName, videoTag) // fileNames := strings.Split(fileName, videoTag)
if len(fileNames) == 2 { // if len(fileNames) == 2 {
fileName = fileNames[1] // fileName = fileNames[0]
targetFilePath := filePath + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + fileName // split := strings.Split(fileName, string(os.PathSeparator))
err := os.Rename(videoFilePath, targetFilePath) // if len(split) > 0 {
if err != nil { // realFileName := split[len(split)-1]
fmt.Printf("=== 重命名异常: %s \n", videoFilePath) // //targetFilePath := filePath + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + fileName
} // ext := filepath.Ext(fileNames[1])
} // lowExt := strings.ToLower(ext)
} else { // header := strings.ReplaceAll(realFileName, ext, "")
targetFilePath := filePath + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + " - " + fileName // targetFilePath := filePath + header + videoTag + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + lowExt
// err := os.Rename(videoFilePath, targetFilePath)
// if err != nil {
// fmt.Printf("=== 重命名异常: %s \n", videoFilePath)
// }
// }
// }
//} else {
// //targetFilePath := filePath + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + " - " + fileName
// ext := filepath.Ext(fileName)
// lowExt := strings.ToLower(ext)
// header := strings.ReplaceAll(fileName, ext, "")
// targetFilePath := filePath + header + videoTag + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + lowExt
// err := os.Rename(videoFilePath, targetFilePath)
// if err != nil {
// fmt.Printf("=== 重命名异常: %s \n", videoFilePath)
// }
//}
if strings.Contains(fileName, videoTag) == false {
//targetFilePath := filePath + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + videoTag + " - " + fileName
ext := filepath.Ext(fileName)
lowExt := strings.ToLower(ext)
header := strings.ReplaceAll(fileName, ext, "")
targetFilePath := filePath + header + videoTag + "[" + videoPath2DurationMap[videoFilePath] + "]" + modelType + wh + lowExt
err := os.Rename(videoFilePath, targetFilePath) err := os.Rename(videoFilePath, targetFilePath)
if err != nil { if err != nil {
fmt.Printf("=== 重命名异常: %s \n", videoFilePath) fmt.Printf("=== 重命名异常: %s \n", videoFilePath)
@ -411,12 +446,21 @@ func moveHorizontalVideo(rootDir string) {
if len(horizontalStandard1080PVideoList) > 0 { if len(horizontalStandard1080PVideoList) > 0 {
renameFileV2("[H][1080P]", horizontalStandard1080PVideoList) renameFileV2("[H][1080P]", horizontalStandard1080PVideoList)
} }
if len(horizontalStandard2KVideoList) > 0 {
renameFileV2("[H][2KP]", horizontalStandard2KVideoList)
}
if len(horizontalStandard4KVideoList) > 0 { if len(horizontalStandard4KVideoList) > 0 {
renameFileV2("[H][4KP]", horizontalStandard4KVideoList) renameFileV2("[H][4KP]", horizontalStandard4KVideoList)
} }
if len(horizontalStandard5KVideoList) > 0 {
renameFileV2("[H][5KP]", horizontalStandard5KVideoList)
}
if len(horizontalStandard8KVideoList) > 0 { if len(horizontalStandard8KVideoList) > 0 {
renameFileV2("[H][8KP]", horizontalStandard8KVideoList) renameFileV2("[H][8KP]", horizontalStandard8KVideoList)
} }
if len(horizontalUnHandleVideoList) > 0 {
renameFileV2("[H][UnHandle]", horizontalUnHandleVideoList)
}
} }
// 移动等比视频 // 移动等比视频
@ -451,17 +495,8 @@ func moveSquareVideo(rootDir string) {
if len(squareHKVideoList) > 0 { if len(squareHKVideoList) > 0 {
renameFileV2("[M][原]", squareHKVideoList) renameFileV2("[M][原]", squareHKVideoList)
} }
if len(squareStandard720PVideoList) > 0 { if len(squareUnHandleVideoList) > 0 {
renameFileV2("[M][720P]", squareStandard720PVideoList) renameFileV2("[M][UnHandle]", squareUnHandleVideoList)
}
if len(squareStandard1080PVideoList) > 0 {
renameFileV2("[M][1080P]", squareStandard1080PVideoList)
}
if len(squareStandard4KVideoList) > 0 {
renameFileV2("[M][4KP]", squareStandard4KVideoList)
}
if len(squareStandard8KVideoList) > 0 {
renameFileV2("[M][8KP]", squareStandard8KVideoList)
} }
} }
@ -469,7 +504,6 @@ func moveSquareVideo(rootDir string) {
func moveNormalVideo(rootDir string) { func moveNormalVideo(rootDir string) {
//pathSeparator := string(os.PathSeparator) //pathSeparator := string(os.PathSeparator)
if len(horizontalNormalVideoList) > 0 { if len(horizontalNormalVideoList) > 0 {
//renameFile(rootDir, "[L]", horizontalNormalVideoList, pathSeparator)
renameFileV2("[L]", horizontalNormalVideoList) renameFileV2("[L]", horizontalNormalVideoList)
} }
if len(verticalNormalVideoList) > 0 { if len(verticalNormalVideoList) > 0 {
@ -508,23 +542,31 @@ func handleVerticalVideo(currentVideoPath string, height int, suffix string) {
vertical9KVideoList = append(vertical9KVideoList, currentVideoPath) vertical9KVideoList = append(vertical9KVideoList, currentVideoPath)
} else if height >= 10000 { } else if height >= 10000 {
verticalHKVideoList = append(verticalHKVideoList, currentVideoPath) verticalHKVideoList = append(verticalHKVideoList, currentVideoPath)
} else {
// 未分类的垂直视频
verticalUnHandleVideoList = append(verticalUnHandleVideoList, currentVideoPath)
} }
} }
// 计算水平分辨率
func caleHorizontalPix(level int) int {
return 1024 * level
}
// 计算垂直分辨率
func caleVerticalPix(level int) int {
return 768 * level
}
// 处理横向视频 // 处理横向视频
func handleHorizontalVideo(currentVideoPath string, width int, height int, suffix string) { func handleHorizontalVideo(currentVideoPath string, width int, height int, suffix string) {
if strings.EqualFold(suffix, ".gif") { if strings.EqualFold(suffix, ".gif") {
horizontalGifVideoList = append(horizontalGifVideoList, currentVideoPath) horizontalGifVideoList = append(horizontalGifVideoList, currentVideoPath)
return return
} }
if width < 1000 { if width < caleHorizontalPix(1) {
// 160 × 120
// 320 × 180
// 320 × 240
// 640 × 360
// 640 × 480
horizontalNormalVideoList = append(horizontalNormalVideoList, currentVideoPath) horizontalNormalVideoList = append(horizontalNormalVideoList, currentVideoPath)
} else if width >= 1000 && width < 2000 { } else if width >= caleHorizontalPix(1) && width < caleHorizontalPix(2) {
// 1280 x 720 -> 720p // 1280 x 720 -> 720p
if width == 1280 && height == 720 { if width == 1280 && height == 720 {
horizontalStandard720PVideoList = append(horizontalStandard720PVideoList, currentVideoPath) horizontalStandard720PVideoList = append(horizontalStandard720PVideoList, currentVideoPath)
@ -536,34 +578,47 @@ func handleHorizontalVideo(currentVideoPath string, width int, height int, suffi
return return
} }
horizontal1KVideoList = append(horizontal1KVideoList, currentVideoPath) horizontal1KVideoList = append(horizontal1KVideoList, currentVideoPath)
} else if width >= 2000 && width < 3000 { } else if width >= caleHorizontalPix(2) && width < caleHorizontalPix(3) {
// 2560 x 1440 -> 2k
if width == 2560 && height == 1440 {
horizontalStandard2KVideoList = append(horizontalStandard2KVideoList, currentVideoPath)
return
}
horizontal2KVideoList = append(horizontal2KVideoList, currentVideoPath) horizontal2KVideoList = append(horizontal2KVideoList, currentVideoPath)
} else if width >= 3000 && width < 4000 { } else if width >= caleHorizontalPix(3) && width < caleHorizontalPix(4) {
// 3840 x 2160 -> 4k // 3840 x 2160 -> 4k
if width == 3840 && height == 2160 { if width == 3840 && height == 2160 {
horizontalStandard4KVideoList = append(horizontalStandard4KVideoList, currentVideoPath) horizontalStandard4KVideoList = append(horizontalStandard4KVideoList, currentVideoPath)
return return
} }
horizontal3KVideoList = append(horizontal3KVideoList, currentVideoPath) horizontal3KVideoList = append(horizontal3KVideoList, currentVideoPath)
} else if width >= 4000 && width < 5000 { } else if width >= caleHorizontalPix(4) && width < caleHorizontalPix(5) {
horizontal4KVideoList = append(horizontal4KVideoList, currentVideoPath) horizontal4KVideoList = append(horizontal4KVideoList, currentVideoPath)
} else if width >= 5000 && width < 6000 { } else if width >= caleHorizontalPix(5) && width < caleHorizontalPix(6) {
// 5120 x 2880 -> 5k
if width == 5120 && height == 2880 {
horizontalStandard5KVideoList = append(horizontalStandard5KVideoList, currentVideoPath)
return
}
horizontal5KVideoList = append(horizontal5KVideoList, currentVideoPath) horizontal5KVideoList = append(horizontal5KVideoList, currentVideoPath)
} else if width >= 6000 && width < 7000 { } else if width >= caleHorizontalPix(6) && width < caleHorizontalPix(7) {
horizontal6KVideoList = append(horizontal6KVideoList, currentVideoPath) horizontal6KVideoList = append(horizontal6KVideoList, currentVideoPath)
} else if width >= 7000 && width < 8000 { } else if width >= caleHorizontalPix(7) && width < caleHorizontalPix(8) {
// 7680 x 4320 -> 8k // 7680 x 4320 -> 8k
if width == 7680 && height == 4320 { if width == 7680 && height == 4320 {
horizontalStandard8KVideoList = append(horizontalStandard8KVideoList, currentVideoPath) horizontalStandard8KVideoList = append(horizontalStandard8KVideoList, currentVideoPath)
return return
} }
horizontal7KVideoList = append(horizontal7KVideoList, currentVideoPath) horizontal7KVideoList = append(horizontal7KVideoList, currentVideoPath)
} else if width >= 8000 && width < 9000 { } else if width >= caleHorizontalPix(8) && width < caleHorizontalPix(9) {
horizontal8KVideoList = append(horizontal8KVideoList, currentVideoPath) horizontal8KVideoList = append(horizontal8KVideoList, currentVideoPath)
} else if width >= 9000 && width < 10000 { } else if width >= caleHorizontalPix(9) && width < caleHorizontalPix(10) {
horizontal9KVideoList = append(horizontal9KVideoList, currentVideoPath) horizontal9KVideoList = append(horizontal9KVideoList, currentVideoPath)
} else if width >= 10000 { } else if width >= caleHorizontalPix(10) {
horizontalHKVideoList = append(horizontalHKVideoList, currentVideoPath) horizontalHKVideoList = append(horizontalHKVideoList, currentVideoPath)
} else {
// 未分类的视频
horizontalUnHandleVideoList = append(horizontalUnHandleVideoList, currentVideoPath)
} }
} }
@ -573,48 +628,31 @@ func handleSquareVideo(currentVideoPath string, width int, height int, suffix st
squareGifVideoList = append(squareGifVideoList, currentVideoPath) squareGifVideoList = append(squareGifVideoList, currentVideoPath)
return return
} }
if width < 1000 { if width < caleHorizontalPix(1) {
squareNormalVideoList = append(squareNormalVideoList, currentVideoPath) squareNormalVideoList = append(squareNormalVideoList, currentVideoPath)
} else if width >= 1000 && width < 2000 { } else if width >= caleHorizontalPix(1) && width < caleHorizontalPix(2) {
// 1280 x 720 -> 720p
if width == 1280 && height == 720 {
squareStandard720PVideoList = append(squareStandard720PVideoList, currentVideoPath)
return
}
// 1920 x 1080 -> 1080p
if width == 1920 && height == 1080 {
squareStandard1080PVideoList = append(squareStandard1080PVideoList, currentVideoPath)
return
}
square1KVideoList = append(square1KVideoList, currentVideoPath) square1KVideoList = append(square1KVideoList, currentVideoPath)
} else if width >= 2000 && width < 3000 { } else if width >= caleHorizontalPix(2) && width < caleHorizontalPix(3) {
square2KVideoList = append(square2KVideoList, currentVideoPath) square2KVideoList = append(square2KVideoList, currentVideoPath)
} else if width >= 3000 && width < 4000 { } else if width >= caleHorizontalPix(3) && width < caleHorizontalPix(4) {
// 3840 x 2160 -> 4k
if width == 3840 && height == 2160 {
squareStandard4KVideoList = append(squareStandard4KVideoList, currentVideoPath)
return
}
square3KVideoList = append(square3KVideoList, currentVideoPath) square3KVideoList = append(square3KVideoList, currentVideoPath)
} else if width >= 4000 && width < 5000 { } else if width >= caleHorizontalPix(4) && width < caleHorizontalPix(5) {
square4KVideoList = append(square4KVideoList, currentVideoPath) square4KVideoList = append(square4KVideoList, currentVideoPath)
} else if width >= 5000 && width < 6000 { } else if width >= caleHorizontalPix(5) && width < caleHorizontalPix(6) {
square5KVideoList = append(square5KVideoList, currentVideoPath) square5KVideoList = append(square5KVideoList, currentVideoPath)
} else if width >= 6000 && width < 7000 { } else if width >= caleHorizontalPix(6) && width < caleHorizontalPix(7) {
square6KVideoList = append(square6KVideoList, currentVideoPath) square6KVideoList = append(square6KVideoList, currentVideoPath)
} else if width >= 7000 && width < 8000 { } else if width >= caleHorizontalPix(7) && width < caleHorizontalPix(8) {
// 7680 x 4320 -> 8k
if width == 7680 && height == 4320 {
squareStandard8KVideoList = append(squareStandard8KVideoList, currentVideoPath)
return
}
square7KVideoList = append(square7KVideoList, currentVideoPath) square7KVideoList = append(square7KVideoList, currentVideoPath)
} else if width >= 8000 && width < 9000 { } else if width >= caleHorizontalPix(8) && width < caleHorizontalPix(9) {
square8KVideoList = append(square8KVideoList, currentVideoPath) square8KVideoList = append(square8KVideoList, currentVideoPath)
} else if width >= 9000 && width < 10000 { } else if width >= caleHorizontalPix(9) && width < caleHorizontalPix(10) {
square9KVideoList = append(square9KVideoList, currentVideoPath) square9KVideoList = append(square9KVideoList, currentVideoPath)
} else if width >= 10000 { } else if width >= caleHorizontalPix(10) {
squareHKVideoList = append(squareHKVideoList, currentVideoPath) squareHKVideoList = append(squareHKVideoList, currentVideoPath)
} else {
// 未处理的等比视频
squareUnHandleVideoList = append(squareUnHandleVideoList, currentVideoPath)
} }
} }