Skip to content

Commit

Permalink
音频编码逐步改为ogg
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyiming748 committed Jan 3, 2024
1 parent 451937e commit cdb0782
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions conf.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# mission = image
# mission = rotate
# mission = resize
mission = avmerger
# mission = avmerger
# mission = extractAAC
# mission = speedUpAudio
mission = speedUpAudio
# mission = speedUpVideo
# mission = gif
# mission = encoder
Expand All @@ -32,7 +32,7 @@ txt = txt
[root]
folder = /Users/zen/git
image = /Volumes/noname
audio = /mnt/e/audio
audio = /Users/zen/Downloads/Telegram Desktop
video = /mnt/f/large/artistress/littleSubGirl
gif = /Users/zen/Downloads/Fugtrup collection/archive/webp
txt = /Users/zen/Downloads/tele
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func main() {
slog.Debug("开始提取哔哩哔哩音频进程", slog.String("根目录", root))
merge.ExtractAAC(root)
case "speedUpAudio":
root = util.GetVal("root", "speedUp")
root = util.GetVal("root", "audio")
pattern = util.GetVal("pattern", "audio")
pattern = strings.Join([]string{pattern, strings.ToUpper(pattern)}, ";")
speed := util.GetVal("speed", "audition")
Expand Down
4 changes: 2 additions & 2 deletions processAudio/aac.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
func Audio2AAC(in GetFileInfo.BasicInfo) {
// 执行转换
fname := replace.ForFileName(in.PurgeName)
out := strings.Join([]string{in.PurgePath, fname, ".aac"}, "")
cmd := exec.Command("ffmpeg", "-i", in.FullPath, "-ac", "1", out)
out := strings.Join([]string{in.PurgePath, fname, ".ogg"}, "")
cmd := exec.Command("ffmpeg", "-i", in.FullPath, "-c:a", "libvorbis", "-ac", "1", out)
err := util.ExecCommand(cmd)

if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion processAudio/ogg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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, out)
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 {
Expand Down
4 changes: 2 additions & 2 deletions processAudio/speedUp.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func SpeedupAudio(in GetFileInfo.BasicInfo, speed string) {
dst := strings.Join([]string{in.PurgePath, "speed"}, "") //目标文件目录
os.Mkdir(dst, 0777)
fname := replace.ForFileName(in.PurgeName)
fname = strings.Join([]string{fname, "aac"}, ".")
fname = strings.Join([]string{fname, "ogg"}, ".")
slog.Debug("补全后的 fname", slog.String("fname", fname))
out := strings.Join([]string{dst, fname}, string(os.PathSeparator))
slog.Debug("io", slog.String("输入文件", in.FullPath), slog.String("输出文件", out))
Expand All @@ -62,7 +62,7 @@ func SpeedupAudio(in GetFileInfo.BasicInfo, speed string) {
func speedUp(in, out string, speed string) {
ff := audition2ffmpeg(speed)
atempo := strings.Join([]string{"atempo", ff}, "=")
cmd := exec.Command("ffmpeg", "-i", in, "-filter:a", atempo, "-vn", "-ac", "1", out)
cmd := exec.Command("ffmpeg", "-i", in, "-filter:a", atempo, "-vn", "-c:a", "libvorbis", "-ac", "1", out)
util.ExecCommand(cmd)
if err := os.RemoveAll(in); err != nil {
slog.Warn("删除失败", slog.String("源文件", in), slog.Any("错误内容", err))
Expand Down
2 changes: 1 addition & 1 deletion processVideo/h265.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func ProcessVideo2H265(in GetFileInfo.BasicInfo, threads string) {
slog.Debug("", slog.String("out", out), slog.String("extName", in.PurgeExt))
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", "aac", "-ac", "1", "-tag:v", "hvc1", "-map_chapters", "-1", "-threads", threads, 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"}, "")
Expand Down

0 comments on commit cdb0782

Please sign in to comment.