From 5fe7980ae357bcdf118ea57ebfaa556bdd6048a7 Mon Sep 17 00:00:00 2001 From: zen Date: Tue, 9 Jan 2024 22:01:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E8=BD=AC=E6=8D=A2ogg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf.ini | 8 ++++---- processAudio/ogg.go | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/conf.ini b/conf.ini index ae3eba6..e627e79 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 = /Users/zen/Downloads/Telegram Desktop -video = /mnt/f/Downloads/武林外传/50 +audio = /mnt/f/music/audio +video = /mnt/f/Downloads/武林外传/60 gif = /Users/zen/Downloads/Fugtrup collection/archive/webp txt = /Users/zen/Downloads/tele bilibili = /mnt/d/git/processAll/merge/downloads diff --git a/processAudio/ogg.go b/processAudio/ogg.go index 563af93..10cfab1 100644 --- a/processAudio/ogg.go +++ b/processAudio/ogg.go @@ -1,6 +1,8 @@ package processAudio import ( + "log/slog" + "os" "os/exec" "processAll/GetFileInfo" "processAll/replace" @@ -13,15 +15,15 @@ func Audio2OGG(in GetFileInfo.BasicInfo) { fname := replace.ForFileName(in.PurgeName) //fname=r out := strings.Join([]string{in.PurgePath, fname, ".ogg"}, "") - cmd := exec.Command("ffmpeg", "-i", in.FullPath, "-c:a", "libvorbis", out) - _ = util.ExecCommand(cmd) - //if err == nil { - // if err = os.RemoveAll(in.FullPath); err != nil { - // slog.Warn("删除失败", slog.String("源文件", in.FullPath), slog.Any("错误", err)) - // } else { - // slog.Debug("删除成功", slog.String("源文件", in.FullPath)) - // } - //} + cmd := exec.Command("ffmpeg", "-i", in.FullPath, "-ac", "1", "-c:a", "libvorbis", out) + err := util.ExecCommand(cmd) + if err == nil { + if err = os.RemoveAll(in.FullPath); err != nil { + slog.Warn("删除失败", slog.String("源文件", in.FullPath), slog.Any("错误", err)) + } else { + slog.Debug("删除成功", slog.String("源文件", in.FullPath)) + } + } } func Audios2OGG(dir, pattern string) {