Skip to content

Commit

Permalink
生成MD5浪费时间
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyiming748 committed Jan 19, 2024
1 parent 9ada2bd commit 18b92ef
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 32 deletions.
2 changes: 1 addition & 1 deletion GetFileInfo/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
18 changes: 0 additions & 18 deletions GetFileInfo/preload.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ package GetFileInfo
import (
"crypto/md5"
"encoding/hex"
"fmt"
"github.com/zhangyiming748/filetype"
"io"
"log/slog"
"os"
"os/exec"
"regexp"
)

/*
Expand Down Expand Up @@ -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
}
5 changes: 0 additions & 5 deletions GetFileInfo/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
8 changes: 4 additions & 4 deletions conf.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[main]
# mission = i&v
# mission = video
mission = OGG
mission = video
# mission = OGG
# mission = audio
# mission = image
# mission = rotate
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions processVideo/h265.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 18b92ef

Please sign in to comment.