From 62872ee93331a1366327bb960d9e53e954f75b46 Mon Sep 17 00:00:00 2001 From: Matjaz Debelak Date: Fri, 29 Nov 2024 10:37:33 +0100 Subject: [PATCH 1/2] Change AAC encoder to provide CBR --- services/transcode/audio.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/transcode/audio.go b/services/transcode/audio.go index d421543..1da1fe9 100644 --- a/services/transcode/audio.go +++ b/services/transcode/audio.go @@ -108,7 +108,7 @@ func AudioAac(input common.AudioInput, cb ffmpeg.ProgressCallback) (*common.Audi "-progress", "pipe:1", "-hide_banner", "-i", input.Path.Local(), - "-c:a", "aac", + "-c:a", "libfdk_aac", "-b:a", input.Bitrate, } @@ -293,7 +293,6 @@ func AudioMP3(input common.AudioInput, cb ffmpeg.ProgressCallback) (*common.Audi params = append(params, "-q:a", fmt.Sprint(getQfactorFromBitrate(input.Bitrate))) } - outputFilePath := filepath.Join(input.DestinationPath.Local(), input.Path.Base()) outputFilePath = fmt.Sprintf("%s-%s.mp3", outputFilePath[:len(outputFilePath)-len(filepath.Ext(outputFilePath))], input.Bitrate) From 2aca1ca07f76fec7145fd39a2980226380b6e14b Mon Sep 17 00:00:00 2001 From: Matjaz Debelak Date: Fri, 29 Nov 2024 11:27:02 +0100 Subject: [PATCH 2/2] Cheeck if AAC encoder is available on startup --- cmd/worker/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/worker/main.go b/cmd/worker/main.go index 71fed2f..10ab7a5 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "os/exec" "reflect" "runtime" "strconv" @@ -80,6 +81,23 @@ func main() { panic(err) } + if environment.GetQueue() == environment.QueueAudio { + // Test if the libfdk_aac encoder is available + cmd := exec.Command("ffmpeg", "-xerror", + "-f", "lavfi", "-xerror", + "-i", "sine=frequency=1000:duration=0.1", + "-c:a", "libfdk_aac", + "-f", "null", "-") + + err := cmd.Run() + if err != nil { + panic(err) + } + + if cmd.ProcessState.ExitCode() != 0 { + panic("audio worker must support ffmpeg with libfdk_aac") + } + } workerOptions := worker.Options{ DeadlockDetectionTimeout: time.Hour * 3, DisableRegistrationAliasing: true, // Recommended according to readme, default false for backwards compatibility