Skip to content

Commit

Permalink
add qaac
Browse files Browse the repository at this point in the history
  • Loading branch information
vladaad committed Aug 22, 2023
1 parent 1ce68f1 commit d06bca2
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
2 changes: 2 additions & 0 deletions encoder/audio/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ func EncodeAudio(video *settings.Vid, wg *sync.WaitGroup) *settings.Vid {
encFDK(video, dec)
case "fhgaac":
encFHG(video, dec)
case "qaac":
encQaac(video, dec)
}

if !settings.Encoding.FastMode {
Expand Down
54 changes: 54 additions & 0 deletions encoder/audio/qaac.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package audio

import (
"github.com/vladaad/discordcompressor/settings"
"io"
"log"
"os"
"os/exec"
"strconv"
"strings"
)

func encQaac(video *settings.Vid, input io.ReadCloser) {
var options []string
var encoderSettings []string
if video.Output.AEncoder.Args != "" {
encoderSettings = strings.Split(video.Output.AEncoder.Args, " ")
}

// encoding
if encoderSettings != nil {
options = append(options, encoderSettings...)
}
if !video.Output.AEncoder.TVBR {
options = append(options, "-a", strconv.Itoa(video.Output.Bitrate.Audio))
}
// input
options = append(options, "-")
// output
options = append(options, "-o", video.Output.AudioFile)

if settings.Debug {
log.Println(options)
}

// running
cmd := exec.Command(settings.General.QaacExecutable, options...)

cmd.Stdin = input

if !settings.Encoding.FastMode {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}

err := cmd.Start()
if err != nil {
panic(err)
}
err = cmd.Wait()
if err != nil {
panic(err)
}
}
13 changes: 12 additions & 1 deletion settings/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,18 @@ func genFastestEncoder() *Encoder {

func genAACEncoder() *AudioEncoder {
var encoder *AudioEncoder
if utils.CheckIfPresent("fhgaacenc") {

if utils.CheckIfPresent("qaac64") {
encoder = &AudioEncoder{
Name: "aac",
Type: "qaac",
BMult: 1.2,
BMax: 144,
BMin: 72,
TVBR: false,
Args: "",
}
} else if utils.CheckIfPresent("fhgaacenc") {
encoder = &AudioEncoder{
Name: "aac",
Type: "fhgaac",
Expand Down

0 comments on commit d06bca2

Please sign in to comment.