Skip to content

Commit

Permalink
Merge pull request #353 from bcc-code/feat/aac-cbr
Browse files Browse the repository at this point in the history
Change AAC encoder to provide CBR
  • Loading branch information
KillerX authored Nov 29, 2024
2 parents 8567d07 + 2aca1ca commit 81b8202
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 18 additions & 0 deletions cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"os/exec"
"reflect"
"runtime"
"strconv"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions services/transcode/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 81b8202

Please sign in to comment.