From 18b92efcc5dcef98c0a33c9b9332b77eb8728ddc Mon Sep 17 00:00:00 2001 From: zen Date: Fri, 19 Jan 2024 10:01:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90MD5=E6=B5=AA=E8=B4=B9?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GetFileInfo/basic.go | 2 +- GetFileInfo/preload.go | 18 ------------------ GetFileInfo/unit_test.go | 5 ----- conf.ini | 8 ++++---- processVideo/h265.go | 4 ---- 5 files changed, 5 insertions(+), 32 deletions(-) diff --git a/GetFileInfo/basic.go b/GetFileInfo/basic.go index b312968..659abc6 100644 --- a/GetFileInfo/basic.go +++ b/GetFileInfo/basic.go @@ -51,7 +51,7 @@ func GetFileInfo(absPath string) BasicInfo { PurgeName: strings.Replace(file, ext, "", 1), PurgeExt: strings.Replace(ext, ".", "", 1), PurgePath: dir, - MD5: GetMD5(absPath), + //MD5: GetMD5(absPath), } // todo 测试使用文件头判断文件类型 //t := SelectType(strings.Replace(ext, ".", "", 1)) diff --git a/GetFileInfo/preload.go b/GetFileInfo/preload.go index b4e1e68..0b7416e 100644 --- a/GetFileInfo/preload.go +++ b/GetFileInfo/preload.go @@ -3,13 +3,10 @@ package GetFileInfo import ( "crypto/md5" "encoding/hex" - "fmt" "github.com/zhangyiming748/filetype" "io" "log/slog" "os" - "os/exec" - "regexp" ) /* @@ -167,18 +164,3 @@ func SelectType(ext string) string { return "General" } } - -func GetBitRate(fp string) (string, error) { - ff, _ := exec.Command("ffmpeg", "-i", fp).CombinedOutput() - re := regexp.MustCompile(`bitrate:\s*(\d+)\s*kb/s`) - matches := re.FindAllStringSubmatch(string(ff), -1) - if len(matches) > 0 { - str := fmt.Sprintf("比特率字段:%s\n", matches) - fmt.Println(str) - num := fmt.Sprint(matches[0][1]) - slog.Debug(num) - return num, nil - } - - return "", nil -} diff --git a/GetFileInfo/unit_test.go b/GetFileInfo/unit_test.go index cc3752d..cdc6635 100644 --- a/GetFileInfo/unit_test.go +++ b/GetFileInfo/unit_test.go @@ -74,9 +74,4 @@ func TestIsNotH265(t *testing.T) { // go test -v -run TestGetBitRate ./ func TestGetBitRate(t *testing.T) { - rate, err := GetBitRate("/media/zen/Disk2/video/再見我的愛人.mp4") - if err != nil { - return - } - t.Log(rate) } diff --git a/conf.ini b/conf.ini index e627e79..71bcde0 100644 --- a/conf.ini +++ b/conf.ini @@ -1,7 +1,7 @@ [main] # mission = i&v -# mission = video -mission = OGG +mission = video +# mission = OGG # mission = audio # mission = image # mission = rotate @@ -32,8 +32,8 @@ txt = txt [root] folder = /Users/zen/git image = /Volumes/noname -audio = /mnt/f/music/audio -video = /mnt/f/Downloads/武林外传/60 +audio = /mnt/c/Users/zen/Videos/bili +video = /mnt/f/large/AV/other gif = /Users/zen/Downloads/Fugtrup collection/archive/webp txt = /Users/zen/Downloads/tele bilibili = /mnt/d/git/processAll/merge/downloads diff --git a/processVideo/h265.go b/processVideo/h265.go index d98dc48..8bac142 100644 --- a/processVideo/h265.go +++ b/processVideo/h265.go @@ -70,10 +70,6 @@ func ProcessVideo2H265(in GetFileInfo.BasicInfo, threads string) { mp4 := strings.Replace(out, in.PurgeExt, "mp4", -1) slog.Debug("调试", slog.String("输入文件", in.FullPath), slog.String("输出文件", mp4)) cmd := exec.Command("ffmpeg", "-threads", threads, "-i", in.FullPath, "-c:v", "libx265", "-c:a", "libvorbis", "-ac", "1", "-tag:v", "hvc1", "-map_chapters", "-1", "-threads", threads, mp4) - bitRate, _ := GetFileInfo.GetBitRate(in.FullPath) - slog.Debug("bitrate in h265", slog.String("bitrate", bitRate)) - b := strings.Join([]string{bitRate, "k"}, "") - slog.Debug("获取的比特率", slog.String("bitrate", b)) if mi.VideoWidth > 1920 && mi.VideoHeight > 1920 { slog.Warn("视频大于1080P需要使用其他程序先处理视频尺寸", slog.Any("原视频", in)) ResizeVideo(in, threads)