feat:视频动态整理

This commit is contained in:
2025-02-01 21:14:25 +08:00
parent e216f3581f
commit 0e83c9e6b1
5 changed files with 230 additions and 361 deletions
+2
View File
@@ -1,3 +1,5 @@
# 媒体分辨率分类工具
# 简介
显示器的分辨率:通常表示为水平像素数乘以垂直像素数。
+5 -5
View File
@@ -1,7 +1,7 @@
rm -f OdMediaPicker.exe
rm -f OdMediaPickerRelease.exe
rm -f ImageVideoResolutionPickerTool.exe
rm -f ImageVideoResolutionPickerToolRelease.exe
# build
go build -o OdMediaPicker.exe main.go
go build -o ImageVideoResolutionPickerTool.exe main.go
# upx compress
./upx -o OdMediaPickerRelease.exe OdMediaPicker.exe
rm -f OdMediaPicker.exe
./upx -o ImageVideoResolutionPickerToolRelease.exe ImageVideoResolutionPickerTool.exe
rm -f ImageVideoResolutionPickerTool.exe
+74 -303
View File
@@ -24,21 +24,13 @@ var supportImageTypes = []string{
".jpe",
".png",
".webp",
".psb",
}
// 水平图片
var normalImageList []string
// gif图片
var horizontalGifImageList []string
var horizontal2KImageList []string
var horizontal1KImageList []string
var horizontal3KImageList []string
var horizontal4KImageList []string
var horizontal5KImageList []string
var horizontal6KImageList []string
var horizontal7KImageList []string
var horizontal8KImageList []string
var horizontal9KImageList []string
var horizontalHKImageList []string
var verticalGifImageList []string
var squareGifImageList []string
// 标准横向图片
var horizontalStandard720PImageList []string
@@ -46,40 +38,14 @@ var horizontalStandard1080PImageList []string
var horizontalStandard4KImageList []string
var horizontalStandard8KImageList []string
// 垂直图片
var verticalGifImageList []string
var vertical1KImageList []string
var vertical2KImageList []string
var vertical3KImageList []string
var vertical4KImageList []string
var vertical5KImageList []string
var vertical6KImageList []string
var vertical7KImageList []string
var vertical8KImageList []string
var vertical9KImageList []string
var verticalHKImageList []string
// 等比图片
var squareGifImageList []string
var square1KImageList []string
var square2KImageList []string
var square3KImageList []string
var square4KImageList []string
var square5KImageList []string
var square6KImageList []string
var square7KImageList []string
var square8KImageList []string
var square9KImageList []string
var squareHKImageList []string
// 标准等比图片
var squareStandard720PImageList []string
var squareStandard1080PImageList []string
var squareStandard4KImageList []string
var squareStandard8KImageList []string
// psd图片
var psdImageList []string
// 规格对应图片所在的路径
var hSpecs2ImageList = make(map[string][]string)
var vSpecs2ImageList = make(map[string][]string)
var mSpecs2ImageList = make(map[string][]string)
func DoHandleImage(rootDir string) {
total := len(vars.GlobalImagePathList) // 总数
successCount := 0 // 成功数
@@ -133,19 +99,19 @@ func DoHandleImage(rootDir string) {
}
uid := strings.ReplaceAll(uuid.NewV4().String(), "-", "")
if len(psdImageList) > 0 {
psdImagePath := rootDir + string(os.PathSeparator) + uid + "_图片_PSD"
psdImagePath := rootDir + string(os.PathSeparator) + uid + "-图片_PSD"
if util.CreateDir(psdImagePath) {
doMoveFileToDir(psdImageList, psdImagePath)
}
}
if len(readErrorImagePathList) > 0 {
readInfoErrorPath := rootDir + string(os.PathSeparator) + uid + "_图片_读取异常"
readInfoErrorPath := rootDir + string(os.PathSeparator) + uid + "-图片_读取异常"
if util.CreateDir(readInfoErrorPath) {
doMoveFileToDir(readErrorImagePathList, readInfoErrorPath)
}
}
if len(ignoreImagePathList) > 0 {
ignorePath := rootDir + string(os.PathSeparator) + uid + "_图片_已忽略"
ignorePath := rootDir + string(os.PathSeparator) + uid + "-图片_已忽略"
if util.CreateDir(ignorePath) {
doMoveFileToDir(ignoreImagePathList, ignorePath)
}
@@ -170,248 +136,83 @@ func doPickImageFile(uid string, rootDir string, imagePath2WidthHeightMap map[st
continue
}
if width < height {
handleVerticalImage(currentImagePath, height, suffix)
handleVerticalImage(currentImagePath, width, height, suffix)
continue
}
handleSquareImage(currentImagePath, width, height, suffix)
}
moveNormalImage(rootDir, uid)
moveHorizontalImage(rootDir, uid)
moveVerticalImage(rootDir, uid)
moveSquareImage(rootDir, uid)
moveStandardHorizontalImage(rootDir, uid)
moveStandardVerticalImage(rootDir, uid)
moveStandardSquareImage(rootDir, uid)
// 移动特殊规格的
moveSpecsHorizontalImage(rootDir, uid)
moveSpecsVerticalImage(rootDir, uid)
moveSpecsSquareImage(rootDir, uid)
}
func moveSquareImage(rootDir string, uid string) {
func moveStandardSquareImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
squareGifImagePath := rootDir + pathSeparator + uid + "_图片_等比_GIF"
square1KImagePath := rootDir + pathSeparator + uid + "_图片_等比_1k"
square2KImagePath := rootDir + pathSeparator + uid + "_图片_等比_2k"
square3KImagePath := rootDir + pathSeparator + uid + "_图片_等比_3k"
square4KImagePath := rootDir + pathSeparator + uid + "_图片_等比_4k"
square5KImagePath := rootDir + pathSeparator + uid + "_图片_等比_5k"
square6KImagePath := rootDir + pathSeparator + uid + "_图片_等比_6k"
square7KImagePath := rootDir + pathSeparator + uid + "_图片_等比_7k"
square8KImagePath := rootDir + pathSeparator + uid + "_图片_等比_8k"
square9KImagePath := rootDir + pathSeparator + uid + "_图片_等比_9k"
squareHKImagePath := rootDir + pathSeparator + uid + "_图片_等比_原图"
squareGifImagePath := rootDir + pathSeparator + uid + "-图片_等比_GIF"
if len(squareGifImageList) > 0 {
util.CreateDir(squareGifImagePath)
doMoveFileToDir(squareGifImageList, squareGifImagePath)
}
if len(square1KImageList) > 0 {
util.CreateDir(square1KImagePath)
doMoveFileToDir(square1KImageList, square1KImagePath)
}
if len(square2KImageList) > 0 {
util.CreateDir(square2KImagePath)
doMoveFileToDir(square2KImageList, square2KImagePath)
}
if len(square3KImageList) > 0 {
util.CreateDir(square3KImagePath)
doMoveFileToDir(square3KImageList, square3KImagePath)
}
if len(square4KImageList) > 0 {
util.CreateDir(square4KImagePath)
doMoveFileToDir(square4KImageList, square4KImagePath)
}
if len(square5KImageList) > 0 {
util.CreateDir(square5KImagePath)
doMoveFileToDir(square5KImageList, square5KImagePath)
}
if len(square6KImageList) > 0 {
util.CreateDir(square6KImagePath)
doMoveFileToDir(square6KImageList, square6KImagePath)
}
if len(square7KImageList) > 0 {
util.CreateDir(square7KImagePath)
doMoveFileToDir(square7KImageList, square7KImagePath)
}
if len(square8KImageList) > 0 {
util.CreateDir(square8KImagePath)
doMoveFileToDir(square8KImageList, square8KImagePath)
}
if len(square9KImageList) > 0 {
util.CreateDir(square9KImagePath)
doMoveFileToDir(square9KImageList, square9KImagePath)
}
if len(squareHKImageList) > 0 {
util.CreateDir(squareHKImagePath)
doMoveFileToDir(squareHKImageList, squareHKImagePath)
}
func moveSpecsSquareImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
for dirName := range mSpecs2ImageList {
imagePath := rootDir + pathSeparator + uid + "-" + dirName
if len(mSpecs2ImageList[dirName]) > 0 {
util.CreateDir(imagePath)
doMoveFileToDir(mSpecs2ImageList[dirName], imagePath)
}
}
}
func handleSquareImage(currentImagePath string, width int, height int, suffix string) {
if strings.EqualFold(suffix, ".gif") {
squareGifImageList = append(squareGifImageList, currentImagePath)
return
}
if width < 1000 {
normalImageList = append(normalImageList, currentImagePath)
} else if width >= 1000 && width < 2000 {
// 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)
} else if width >= 2000 && width < 3000 {
square2KImageList = append(square2KImageList, currentImagePath)
} else if width >= 3000 && width < 4000 {
// 3840 x 2160 -> 4k
if width == 3840 && height == 2160 {
squareStandard4KImageList = append(squareStandard4KImageList, currentImagePath)
return
}
square3KImageList = append(square3KImageList, currentImagePath)
} else if width >= 4000 && width < 5000 {
square4KImageList = append(square4KImageList, currentImagePath)
} else if width >= 5000 && width < 6000 {
square5KImageList = append(square5KImageList, currentImagePath)
} else if width >= 6000 && width < 7000 {
square6KImageList = append(square6KImageList, currentImagePath)
} else if width >= 7000 && width < 8000 {
// 7680 x 4320 -> 8k
if width == 7680 && height == 4320 {
squareStandard8KImageList = append(squareStandard8KImageList, currentImagePath)
return
}
square7KImageList = append(square7KImageList, currentImagePath)
} else if width >= 8000 && width < 9000 {
square8KImageList = append(square8KImageList, currentImagePath)
} else if width >= 9000 && width < 10000 {
square9KImageList = append(square9KImageList, currentImagePath)
} else if width >= 10000 {
squareHKImageList = append(squareHKImageList, currentImagePath)
// 非标准规格图片处理
prefix := fmt.Sprintf("M_%d_%d", width, height)
if mSpecs2ImageList[prefix] == nil {
mSpecs2ImageList[prefix] = make([]string, 1)
}
mSpecs2ImageList[prefix] = append(mSpecs2ImageList[prefix], currentImagePath)
}
// 移动垂直图片
func moveVerticalImage(rootDir string, uid string) {
func moveStandardVerticalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
verticalGifImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_GIF"
vertical1KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_1k"
vertical2KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_2k"
vertical3KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_3k"
vertical4KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_4k"
vertical5KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_5k"
vertical6KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_6k"
vertical7KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_7k"
vertical8KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_8k"
vertical9KImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_9k"
verticalHKImagePath := rootDir + pathSeparator + uid + "_图片_竖屏_原图"
verticalGifImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_GIF"
if len(verticalGifImageList) > 0 {
util.CreateDir(verticalGifImagePath)
doMoveFileToDir(verticalGifImageList, verticalGifImagePath)
}
if len(vertical1KImageList) > 0 {
util.CreateDir(vertical1KImagePath)
doMoveFileToDir(vertical1KImageList, vertical1KImagePath)
}
if len(vertical2KImageList) > 0 {
util.CreateDir(vertical2KImagePath)
doMoveFileToDir(vertical2KImageList, vertical2KImagePath)
}
if len(vertical3KImageList) > 0 {
util.CreateDir(vertical3KImagePath)
doMoveFileToDir(vertical3KImageList, vertical3KImagePath)
}
if len(vertical4KImageList) > 0 {
util.CreateDir(vertical4KImagePath)
doMoveFileToDir(vertical4KImageList, vertical4KImagePath)
}
if len(vertical5KImageList) > 0 {
util.CreateDir(vertical5KImagePath)
doMoveFileToDir(vertical5KImageList, vertical5KImagePath)
}
if len(vertical6KImageList) > 0 {
util.CreateDir(vertical6KImagePath)
doMoveFileToDir(vertical6KImageList, vertical6KImagePath)
}
if len(vertical7KImageList) > 0 {
util.CreateDir(vertical7KImagePath)
doMoveFileToDir(vertical7KImageList, vertical7KImagePath)
}
if len(vertical8KImageList) > 0 {
util.CreateDir(vertical8KImagePath)
doMoveFileToDir(vertical8KImageList, vertical8KImagePath)
}
if len(vertical9KImageList) > 0 {
util.CreateDir(vertical9KImagePath)
doMoveFileToDir(vertical9KImageList, vertical9KImagePath)
}
if len(verticalHKImageList) > 0 {
util.CreateDir(verticalHKImagePath)
doMoveFileToDir(verticalHKImageList, verticalHKImagePath)
}
func moveSpecsVerticalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
for dirName := range vSpecs2ImageList {
imagePath := rootDir + pathSeparator + uid + "-" + dirName
if len(vSpecs2ImageList[dirName]) > 0 {
util.CreateDir(imagePath)
doMoveFileToDir(vSpecs2ImageList[dirName], imagePath)
}
}
}
// 移动水平图片
func moveHorizontalImage(rootDir string, uid string) {
func moveStandardHorizontalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
horizontalGifImagePath := rootDir + pathSeparator + uid + "_图片_横屏_GIF"
horizontal1KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_1k"
horizontal2KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_2k"
horizontal3KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_3k"
horizontal4KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_4k"
horizontal5KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_5k"
horizontal6KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_6k"
horizontal7KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_7k"
horizontal8KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_8k"
horizontal9KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_9k"
horizontalHKImagePath := rootDir + pathSeparator + uid + "_图片_横屏_原图"
horizontalStandard720PImagePath := rootDir + pathSeparator + uid + "_图片_横屏_720P"
horizontalStandard1080PImagePath := rootDir + pathSeparator + uid + "_图片_横屏_1080P"
horizontalStandard4KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_4KP"
horizontalStandard8KImagePath := rootDir + pathSeparator + uid + "_图片_横屏_8KP"
horizontalGifImagePath := rootDir + pathSeparator + uid + "-图片_横屏_GIF"
horizontalStandard720PImagePath := rootDir + pathSeparator + uid + "-图片_横屏_720P"
horizontalStandard1080PImagePath := rootDir + pathSeparator + uid + "-图片_横屏_1080P"
horizontalStandard4KImagePath := rootDir + pathSeparator + uid + "-图片_横屏_4KP"
horizontalStandard8KImagePath := rootDir + pathSeparator + uid + "-图片_横屏_8KP"
if len(horizontalGifImageList) > 0 {
util.CreateDir(horizontalGifImagePath)
doMoveFileToDir(horizontalGifImageList, horizontalGifImagePath)
}
if len(horizontal1KImageList) > 0 {
util.CreateDir(horizontal1KImagePath)
doMoveFileToDir(horizontal1KImageList, horizontal1KImagePath)
}
if len(horizontal2KImageList) > 0 {
util.CreateDir(horizontal2KImagePath)
doMoveFileToDir(horizontal2KImageList, horizontal2KImagePath)
}
if len(horizontal3KImageList) > 0 {
util.CreateDir(horizontal3KImagePath)
doMoveFileToDir(horizontal3KImageList, horizontal3KImagePath)
}
if len(horizontal4KImageList) > 0 {
util.CreateDir(horizontal4KImagePath)
doMoveFileToDir(horizontal4KImageList, horizontal4KImagePath)
}
if len(horizontal5KImageList) > 0 {
util.CreateDir(horizontal5KImagePath)
doMoveFileToDir(horizontal5KImageList, horizontal5KImagePath)
}
if len(horizontal6KImageList) > 0 {
util.CreateDir(horizontal6KImagePath)
doMoveFileToDir(horizontal6KImageList, horizontal6KImagePath)
}
if len(horizontal7KImageList) > 0 {
util.CreateDir(horizontal7KImagePath)
doMoveFileToDir(horizontal7KImageList, horizontal7KImagePath)
}
if len(horizontal8KImageList) > 0 {
util.CreateDir(horizontal8KImagePath)
doMoveFileToDir(horizontal8KImageList, horizontal8KImagePath)
}
if len(horizontal9KImageList) > 0 {
util.CreateDir(horizontal9KImagePath)
doMoveFileToDir(horizontal9KImageList, horizontal9KImagePath)
}
if len(horizontalHKImageList) > 0 {
util.CreateDir(horizontalHKImagePath)
doMoveFileToDir(horizontalHKImageList, horizontalHKImagePath)
}
if len(horizontalStandard720PImageList) > 0 {
util.CreateDir(horizontalStandard720PImagePath)
doMoveFileToDir(horizontalStandard720PImageList, horizontalStandard720PImagePath)
@@ -429,46 +230,29 @@ func moveHorizontalImage(rootDir string, uid string) {
doMoveFileToDir(horizontalStandard8KImageList, horizontalStandard8KImagePath)
}
}
// 移动图片
func moveNormalImage(rootDir string, uid string) {
func moveSpecsHorizontalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
allNormalImagePath := rootDir + pathSeparator + uid + "_图片_普通"
if len(normalImageList) > 0 {
util.CreateDir(allNormalImagePath)
doMoveFileToDir(normalImageList, allNormalImagePath)
for dirName := range hSpecs2ImageList {
imagePath := rootDir + pathSeparator + uid + "-" + dirName
if len(hSpecs2ImageList[dirName]) > 0 {
util.CreateDir(imagePath)
doMoveFileToDir(hSpecs2ImageList[dirName], imagePath)
}
}
}
// 处理垂直图片
func handleVerticalImage(currentImagePath string, height int, suffix string) {
func handleVerticalImage(currentImagePath string, width int, height int, suffix string) {
if strings.EqualFold(suffix, ".gif") {
verticalGifImageList = append(verticalGifImageList, currentImagePath)
return
}
if height < 1000 {
normalImageList = append(normalImageList, currentImagePath)
} else if height >= 1000 && height < 2000 {
vertical1KImageList = append(vertical1KImageList, currentImagePath)
} else if height >= 2000 && height < 3000 {
vertical2KImageList = append(vertical2KImageList, currentImagePath)
} else if height >= 3000 && height < 4000 {
vertical3KImageList = append(vertical3KImageList, currentImagePath)
} else if height >= 4000 && height < 5000 {
vertical4KImageList = append(vertical4KImageList, currentImagePath)
} else if height >= 5000 && height < 6000 {
vertical5KImageList = append(vertical5KImageList, currentImagePath)
} else if height >= 6000 && height < 7000 {
vertical6KImageList = append(vertical6KImageList, currentImagePath)
} else if height >= 7000 && height < 8000 {
vertical7KImageList = append(vertical7KImageList, currentImagePath)
} else if height >= 8000 && height < 9000 {
vertical8KImageList = append(vertical8KImageList, currentImagePath)
} else if height >= 9000 && height < 10000 {
vertical9KImageList = append(vertical9KImageList, currentImagePath)
} else if height >= 10000 {
verticalHKImageList = append(verticalHKImageList, currentImagePath)
// 非标准规格图片处理
prefix := fmt.Sprintf("V_%d_%d", width, height)
if vSpecs2ImageList[prefix] == nil {
vSpecs2ImageList[prefix] = make([]string, 1)
}
vSpecs2ImageList[prefix] = append(vSpecs2ImageList[prefix], currentImagePath)
}
// 处理横向图片
@@ -477,9 +261,7 @@ func handleHorizontalImage(currentImagePath string, width int, height int, suffi
horizontalGifImageList = append(horizontalGifImageList, currentImagePath)
return
}
if width < 1000 {
normalImageList = append(normalImageList, currentImagePath)
} else if width >= 1000 && width < 2000 {
if width >= 1000 && width < 2000 {
// 1280 x 720 -> 720p
if width == 1280 && height == 720 {
horizontalStandard720PImageList = append(horizontalStandard720PImageList, currentImagePath)
@@ -490,36 +272,25 @@ func handleHorizontalImage(currentImagePath string, width int, height int, suffi
horizontalStandard1080PImageList = append(horizontalStandard1080PImageList, currentImagePath)
return
}
horizontal1KImageList = append(horizontal1KImageList, currentImagePath)
} else if width >= 2000 && width < 3000 {
horizontal2KImageList = append(horizontal2KImageList, currentImagePath)
} else if width >= 3000 && width < 4000 {
// 3840 x 2160 -> 4k
if width == 3840 && height == 2160 {
horizontalStandard4KImageList = append(horizontalStandard4KImageList, currentImagePath)
return
}
horizontal3KImageList = append(horizontal3KImageList, currentImagePath)
} else if width >= 4000 && width < 5000 {
horizontal4KImageList = append(horizontal4KImageList, currentImagePath)
} else if width >= 5000 && width < 6000 {
horizontal5KImageList = append(horizontal5KImageList, currentImagePath)
} else if width >= 6000 && width < 7000 {
horizontal6KImageList = append(horizontal6KImageList, currentImagePath)
} else if width >= 7000 && width < 8000 {
// 7680 x 4320 -> 8k
if width == 7680 && height == 4320 {
horizontalStandard8KImageList = append(horizontalStandard8KImageList, currentImagePath)
return
}
horizontal7KImageList = append(horizontal7KImageList, currentImagePath)
} else if width >= 8000 && width < 9000 {
horizontal8KImageList = append(horizontal8KImageList, currentImagePath)
} else if width >= 9000 && width < 10000 {
horizontal9KImageList = append(horizontal9KImageList, currentImagePath)
} else if width >= 10000 {
horizontalHKImageList = append(horizontalHKImageList, currentImagePath)
}
// 非标准规格图片处理
prefix := fmt.Sprintf("H_%d_%d", width, height)
if hSpecs2ImageList[prefix] == nil {
hSpecs2ImageList[prefix] = make([]string, 1)
}
hSpecs2ImageList[prefix] = append(hSpecs2ImageList[prefix], currentImagePath)
}
// 判断是否属于支持的图片文件
+147 -51
View File
@@ -7,6 +7,7 @@ import (
_ "embed"
"fmt"
"github.com/redmask-hb/GoSimplePrint/goPrint"
uuid "github.com/satori/go.uuid"
"math"
"os"
"os/exec"
@@ -150,6 +151,7 @@ func DoHandleVideo(rootDir string) {
}
}
doPickVideoFile(rootDir, videoPath2WidthHeightMap)
// 删除ffprobe
if util.CheckFileIsExist(readerFileName) {
_ = os.Remove(readerFileName)
}
@@ -216,6 +218,15 @@ func getVideoResolution(ffmpegExecPath string, filePath string) (width int, heig
height = util.String2int(parts[1])
return width, height, nil
}
resolutionStr = strings.ReplaceAll(resolutionStr, "\r", "")
resolutionStr = strings.ReplaceAll(resolutionStr, "\n", "")
resolutionStr = strings.ReplaceAll(resolutionStr, "N/AxN/A", "")
parts = strings.Split(resolutionStr, "x")
if len(parts) == 2 {
width = util.String2int(parts[0])
height = util.String2int(parts[1])
return width, height, nil
}
return 0, 0, fmt.Errorf("invalid resolution format: %s", resolutionStr)
}
@@ -266,43 +277,65 @@ func doPickVideoFile(rootDir string, videoPath2WidthHeightMap map[string]string)
}
handleSquareVideo(currentVideoPath, width, height, suffix)
}
moveNormalVideo(rootDir)
moveHorizontalVideo(rootDir)
moveVerticalVideo(rootDir)
moveSquareVideo(rootDir)
uid := strings.ReplaceAll(uuid.NewV4().String(), "-", "")
moveNormalVideo(uid, rootDir)
moveHorizontalVideo(uid, rootDir)
moveVerticalVideo(uid, rootDir)
moveSquareVideo(uid, rootDir)
}
// 移动垂直视频
func moveVerticalVideo(rootDir string) {
func moveVerticalVideo(uid string, rootDir string) {
pathSeparator := string(os.PathSeparator)
if len(vertical1KVideoList) > 0 {
renameFileV2("[V][1k]", vertical1KVideoList)
vertical1KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_1k"
util.CreateDir(vertical1KVideoPath)
doMoveFileToDir(vertical1KVideoList, vertical1KVideoPath)
}
if len(vertical2KVideoList) > 0 {
renameFileV2("[V][2k]", vertical2KVideoList)
vertical2KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_2k"
util.CreateDir(vertical2KVideoPath)
doMoveFileToDir(vertical2KVideoList, vertical2KVideoPath)
}
if len(vertical3KVideoList) > 0 {
renameFileV2("[V][3k]", vertical3KVideoList)
vertical3KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_3k"
util.CreateDir(vertical3KVideoPath)
doMoveFileToDir(vertical3KVideoList, vertical3KVideoPath)
}
if len(vertical4KVideoList) > 0 {
renameFileV2("[V][4k]", vertical4KVideoList)
vertical4KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_4k"
util.CreateDir(vertical4KVideoPath)
doMoveFileToDir(vertical4KVideoList, vertical4KVideoPath)
}
if len(vertical5KVideoList) > 0 {
renameFileV2("[V][5k]", vertical5KVideoList)
vertical5KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_5k"
util.CreateDir(vertical5KVideoPath)
doMoveFileToDir(vertical5KVideoList, vertical5KVideoPath)
}
if len(vertical6KVideoList) > 0 {
renameFileV2("[V][6k]", vertical6KVideoList)
vertical6KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_6k"
util.CreateDir(vertical6KVideoPath)
doMoveFileToDir(vertical6KVideoList, vertical6KVideoPath)
}
if len(vertical7KVideoList) > 0 {
renameFileV2("[V][7k]", vertical7KVideoList)
vertical7KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_7k"
util.CreateDir(vertical7KVideoPath)
doMoveFileToDir(vertical7KVideoList, vertical7KVideoPath)
}
if len(vertical8KVideoList) > 0 {
renameFileV2("[V][8k]", vertical8KVideoList)
vertical8KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_8k"
util.CreateDir(vertical8KVideoPath)
doMoveFileToDir(vertical8KVideoList, vertical8KVideoPath)
}
if len(vertical9KVideoList) > 0 {
renameFileV2("[V][9k]", vertical9KVideoList)
vertical9KVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_9k"
util.CreateDir(vertical9KVideoPath)
doMoveFileToDir(vertical9KVideoList, vertical9KVideoPath)
}
if len(verticalHKVideoList) > 0 {
renameFileV2("[V][原]", verticalHKVideoList)
verticalHKVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_原画质"
util.CreateDir(verticalHKVideoPath)
doMoveFileToDir(verticalHKVideoList, verticalHKVideoPath)
}
}
@@ -374,109 +407,172 @@ func renameFileV2(modelType string, videoList []string) {
}
// 移动水平视频
func moveHorizontalVideo(rootDir string) {
func moveHorizontalVideo(uid string, rootDir string) {
pathSeparator := string(os.PathSeparator)
if len(horizontal1KVideoList) > 0 {
renameFileV2("[H][1k]", horizontal1KVideoList)
horizontal1KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_1k"
util.CreateDir(horizontal1KVideoPath)
doMoveFileToDir(horizontal1KVideoList, horizontal1KVideoPath)
}
if len(horizontal2KVideoList) > 0 {
renameFileV2("[H][2k]", horizontal2KVideoList)
horizontal2KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_2k"
util.CreateDir(horizontal2KVideoPath)
doMoveFileToDir(horizontal2KVideoList, horizontal2KVideoPath)
}
if len(horizontal3KVideoList) > 0 {
renameFileV2("[H][3k]", horizontal3KVideoList)
horizontal3KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_3k"
util.CreateDir(horizontal3KVideoPath)
doMoveFileToDir(horizontal3KVideoList, horizontal3KVideoPath)
}
if len(horizontal4KVideoList) > 0 {
renameFileV2("[H][4k]", horizontal4KVideoList)
horizontal4KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_4k"
util.CreateDir(horizontal4KVideoPath)
doMoveFileToDir(horizontal4KVideoList, horizontal4KVideoPath)
}
if len(horizontal5KVideoList) > 0 {
renameFileV2("[H][5k]", horizontal5KVideoList)
horizontal5KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_5k"
util.CreateDir(horizontal5KVideoPath)
doMoveFileToDir(horizontal5KVideoList, horizontal5KVideoPath)
}
if len(horizontal6KVideoList) > 0 {
renameFileV2("[H][6k]", horizontal6KVideoList)
horizontal6KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_6k"
util.CreateDir(horizontal6KVideoPath)
doMoveFileToDir(horizontal6KVideoList, horizontal6KVideoPath)
}
if len(horizontal7KVideoList) > 0 {
renameFileV2("[H][7k]", horizontal7KVideoList)
horizontal7KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_7k"
util.CreateDir(horizontal7KVideoPath)
doMoveFileToDir(horizontal7KVideoList, horizontal7KVideoPath)
}
if len(horizontal8KVideoList) > 0 {
renameFileV2("[H][8k]", horizontal8KVideoList)
horizontal8KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_8k"
util.CreateDir(horizontal8KVideoPath)
doMoveFileToDir(horizontal8KVideoList, horizontal8KVideoPath)
}
if len(horizontal9KVideoList) > 0 {
renameFileV2("[H][9k]", horizontal9KVideoList)
horizontal9KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_9k"
util.CreateDir(horizontal9KVideoPath)
doMoveFileToDir(horizontal9KVideoList, horizontal9KVideoPath)
}
if len(horizontalHKVideoList) > 0 {
renameFileV2("[H][原]", horizontalHKVideoList)
horizontalHKVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_原画质"
util.CreateDir(horizontalHKVideoPath)
doMoveFileToDir(horizontalHKVideoList, horizontalHKVideoPath)
}
if len(horizontalStandard720PVideoList) > 0 {
renameFileV2("[H][720P]", horizontalStandard720PVideoList)
horizontal720PVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_720P"
util.CreateDir(horizontal720PVideoPath)
doMoveFileToDir(horizontalStandard720PVideoList, horizontal720PVideoPath)
}
if len(horizontalStandard1080PVideoList) > 0 {
renameFileV2("[H][1080P]", horizontalStandard1080PVideoList)
horizontal1080PVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_1080P"
util.CreateDir(horizontal1080PVideoPath)
doMoveFileToDir(horizontalStandard1080PVideoList, horizontal1080PVideoPath)
}
if len(horizontalStandard4KVideoList) > 0 {
renameFileV2("[H][4KP]", horizontalStandard4KVideoList)
horizontal4KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_4K"
util.CreateDir(horizontal4KVideoPath)
doMoveFileToDir(horizontalStandard4KVideoList, horizontal4KVideoPath)
}
if len(horizontalStandard8KVideoList) > 0 {
renameFileV2("[H][8KP]", horizontalStandard8KVideoList)
horizontal8KVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_8K"
util.CreateDir(horizontal8KVideoPath)
doMoveFileToDir(horizontalStandard8KVideoList, horizontal8KVideoPath)
}
}
// 移动等比视频
func moveSquareVideo(rootDir string) {
func moveSquareVideo(uid string, rootDir string) {
pathSeparator := string(os.PathSeparator)
if len(square1KVideoList) > 0 {
renameFileV2("[M][1k]", square1KVideoList)
square1KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_1k"
util.CreateDir(square1KVideoPath)
doMoveFileToDir(square1KVideoList, square1KVideoPath)
}
if len(square2KVideoList) > 0 {
renameFileV2("[M][2k]", square2KVideoList)
square2KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_2k"
util.CreateDir(square2KVideoPath)
doMoveFileToDir(square2KVideoList, square2KVideoPath)
}
if len(square3KVideoList) > 0 {
renameFileV2("[M][3k]", square3KVideoList)
square3KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_3k"
util.CreateDir(square3KVideoPath)
doMoveFileToDir(square3KVideoList, square3KVideoPath)
}
if len(square4KVideoList) > 0 {
renameFileV2("[M][4k]", square4KVideoList)
square4KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_4k"
util.CreateDir(square4KVideoPath)
doMoveFileToDir(square4KVideoList, square4KVideoPath)
}
if len(square5KVideoList) > 0 {
renameFileV2("[M][5k]", square5KVideoList)
square5KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_5k"
util.CreateDir(square5KVideoPath)
doMoveFileToDir(square5KVideoList, square5KVideoPath)
}
if len(square6KVideoList) > 0 {
renameFileV2("[M][6k]", square6KVideoList)
square6KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_6k"
util.CreateDir(square6KVideoPath)
doMoveFileToDir(square6KVideoList, square6KVideoPath)
}
if len(square7KVideoList) > 0 {
renameFileV2("[M][7k]", square7KVideoList)
square7KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_7k"
util.CreateDir(square7KVideoPath)
doMoveFileToDir(square7KVideoList, square7KVideoPath)
}
if len(square8KVideoList) > 0 {
renameFileV2("[M][8k]", square8KVideoList)
square8KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_8k"
util.CreateDir(square8KVideoPath)
doMoveFileToDir(square8KVideoList, square8KVideoPath)
}
if len(square9KVideoList) > 0 {
renameFileV2("[M][9k]", square9KVideoList)
square9KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_9k"
util.CreateDir(square9KVideoPath)
doMoveFileToDir(square9KVideoList, square9KVideoPath)
}
if len(squareHKVideoList) > 0 {
renameFileV2("[M][原]", squareHKVideoList)
squareHKVideoPath := rootDir + pathSeparator + uid + "-视频_等比_原画质"
util.CreateDir(squareHKVideoPath)
doMoveFileToDir(squareHKVideoList, squareHKVideoPath)
}
if len(squareStandard720PVideoList) > 0 {
renameFileV2("[M][720P]", squareStandard720PVideoList)
square720PVideoPath := rootDir + pathSeparator + uid + "-视频_等比_720P"
util.CreateDir(square720PVideoPath)
doMoveFileToDir(squareStandard720PVideoList, square720PVideoPath)
}
if len(squareStandard1080PVideoList) > 0 {
renameFileV2("[M][1080P]", squareStandard1080PVideoList)
square1080PVideoPath := rootDir + pathSeparator + uid + "-视频_等比_1080P"
util.CreateDir(square1080PVideoPath)
doMoveFileToDir(squareStandard1080PVideoList, square1080PVideoPath)
}
if len(squareStandard4KVideoList) > 0 {
renameFileV2("[M][4KP]", squareStandard4KVideoList)
square4KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_4K"
util.CreateDir(square4KVideoPath)
doMoveFileToDir(squareStandard4KVideoList, square4KVideoPath)
}
if len(squareStandard8KVideoList) > 0 {
renameFileV2("[M][8KP]", squareStandard8KVideoList)
square8KVideoPath := rootDir + pathSeparator + uid + "-视频_等比_8K"
util.CreateDir(square8KVideoPath)
doMoveFileToDir(squareStandard8KVideoList, square8KVideoPath)
}
}
// 移动普通视频
func moveNormalVideo(rootDir string) {
//pathSeparator := string(os.PathSeparator)
func moveNormalVideo(uid string, rootDir string) {
pathSeparator := string(os.PathSeparator)
if len(horizontalNormalVideoList) > 0 {
//renameFile(rootDir, "[L]", horizontalNormalVideoList, pathSeparator)
renameFileV2("[L]", horizontalNormalVideoList)
horizontalNormalVideoPath := rootDir + pathSeparator + uid + "-视频_横屏_普通"
util.CreateDir(horizontalNormalVideoPath)
doMoveFileToDir(horizontalNormalVideoList, horizontalNormalVideoPath)
}
if len(verticalNormalVideoList) > 0 {
renameFileV2("[L]", verticalNormalVideoList)
verticalNormalVideoPath := rootDir + pathSeparator + uid + "-视频_竖屏_普通"
util.CreateDir(verticalNormalVideoPath)
doMoveFileToDir(verticalNormalVideoList, verticalNormalVideoPath)
}
if len(squareNormalVideoList) > 0 {
renameFileV2("[L]", squareNormalVideoList)
squareNormalVideoPath := rootDir + pathSeparator + uid + "-视频_等比_普通"
util.CreateDir(squareNormalVideoPath)
doMoveFileToDir(squareNormalVideoList, squareNormalVideoPath)
}
}
+2 -2
View File
@@ -1,15 +1,15 @@
module OdMediaPicker
go 1.21
go 1.19
require (
github.com/gabriel-vasile/mimetype v1.4.3
github.com/redmask-hb/GoSimplePrint v0.0.0-20210302075413-3a3af92bcb7d
github.com/satori/go.uuid v1.2.0
golang.org/x/image v0.16.0
)
require (
github.com/redmask-hb/GoSimplePrint v0.0.0-20210302075413-3a3af92bcb7d // indirect
golang.org/x/net v0.17.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)