From 0e3d4b73ce4551853951f6e0329fe15a93c25b3d Mon Sep 17 00:00:00 2001 From: Matthew Balzan <62359563+matthew-balzan@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:32:42 +0200 Subject: [PATCH 1/4] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 738a195..1b8a7bc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +**This is a fork to fix some errors** +==== + dca [![Go report](http://goreportcard.com/badge/jonas747/dca)](http://goreportcard.com/report/jonas747/dca) [![Build Status](https://travis-ci.org/jonas747/dca.svg?branch=master)](https://travis-ci.org/jonas747/dca) ==== `dca` is a audio file format that uses opus packets and json metadata. From f537da0f80e1accdb25132b36846535264134554 Mon Sep 17 00:00:00 2001 From: MatthewBalzan Date: Wed, 18 Oct 2023 21:46:03 +0200 Subject: [PATCH 2/4] fix volume not recognized --- encode.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/encode.go b/encode.go index 640e26b..7d4e149 100644 --- a/encode.go +++ b/encode.go @@ -65,9 +65,6 @@ func (e EncodeOptions) PCMFrameLen() int { // Validate returns an error if the options are not correct func (opts *EncodeOptions) Validate() error { - if opts.Volume < 0 || opts.Volume > 512 { - return errors.New("Out of bounds volume (0-512)") - } if opts.FrameDuration != 20 && opts.FrameDuration != 40 && opts.FrameDuration != 60 { return errors.New("Invalid FrameDuration") @@ -212,7 +209,6 @@ func (e *EncodeSession) run() { "-f", "ogg", "-vbr", vbrStr, "-compression_level", strconv.Itoa(e.options.CompressionLevel), - "-vol", strconv.Itoa(e.options.Volume), "-ar", strconv.Itoa(e.options.FrameRate), "-ac", strconv.Itoa(e.options.Channels), "-b:a", strconv.Itoa(e.options.Bitrate * 1000), @@ -477,7 +473,7 @@ func (e *EncodeSession) handleStderrLine(line string) { _, err := fmt.Sscanf(line, "size=%dkB time=%d:%d:%f bitrate=%fkbits/s speed=%fx", &size, &timeH, &timeM, &timeS, &bitrate, &speed) if err != nil { - logln("Error parsing ffmpeg stats:", err) + //logln("Error parsing ffmpeg stats:", err) } dur := time.Duration(timeH) * time.Hour From 54e1fdc9389968a869fd0a3c4cea1c1c8c440caa Mon Sep 17 00:00:00 2001 From: MatthewBalzan Date: Wed, 16 Oct 2024 18:47:12 +0200 Subject: [PATCH 3/4] fix volume filter --- README.md | 3 --- encode.go | 11 ++++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1b8a7bc..738a195 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -**This is a fork to fix some errors** -==== - dca [![Go report](http://goreportcard.com/badge/jonas747/dca)](http://goreportcard.com/report/jonas747/dca) [![Build Status](https://travis-ci.org/jonas747/dca.svg?branch=master)](https://travis-ci.org/jonas747/dca) ==== `dca` is a audio file format that uses opus packets and json metadata. diff --git a/encode.go b/encode.go index 7d4e149..8241f8d 100644 --- a/encode.go +++ b/encode.go @@ -36,7 +36,7 @@ var ( // EncodeOptions is a set of options for encoding dca type EncodeOptions struct { - Volume int // change audio volume (256=normal) + Volume float32 // change audio volume (1=normal) Channels int // audio channels FrameRate int // audio sampling rate (ex 48000) FrameDuration int // audio frame duration can be 20, 40, or 60 (ms) @@ -66,6 +66,10 @@ func (e EncodeOptions) PCMFrameLen() int { // Validate returns an error if the options are not correct func (opts *EncodeOptions) Validate() error { + if opts.Volume < 0 || opts.Volume > 2 { + return errors.New("Out of bounds volume (0-2)") + } + if opts.FrameDuration != 20 && opts.FrameDuration != 40 && opts.FrameDuration != 60 { return errors.New("Invalid FrameDuration") } @@ -91,7 +95,7 @@ func (opts *EncodeOptions) Validate() error { // StdEncodeOptions is the standard options for encoding var StdEncodeOptions = &EncodeOptions{ - Volume: 256, + Volume: 1, Channels: 2, FrameRate: 48000, FrameDuration: 20, @@ -217,6 +221,7 @@ func (e *EncodeSession) run() { "-packet_loss", strconv.Itoa(e.options.PacketLoss), "-threads", strconv.Itoa(e.options.Threads), "-ss", strconv.Itoa(e.options.StartTime), + "-filter:a", fmt.Sprintf("volume=%.2f", e.options.Volume), } if e.options.AudioFilter != "" { @@ -473,7 +478,7 @@ func (e *EncodeSession) handleStderrLine(line string) { _, err := fmt.Sscanf(line, "size=%dkB time=%d:%d:%f bitrate=%fkbits/s speed=%fx", &size, &timeH, &timeM, &timeS, &bitrate, &speed) if err != nil { - //logln("Error parsing ffmpeg stats:", err) + logln("Error parsing ffmpeg stats:", err) } dur := time.Duration(timeH) * time.Hour From 220ff76d22a1de6e28f3a6ff9382a8fed313e7a1 Mon Sep 17 00:00:00 2001 From: MatthewBalzan Date: Wed, 16 Oct 2024 19:20:08 +0200 Subject: [PATCH 4/4] revert comment --- encode.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encode.go b/encode.go index 8241f8d..3df974c 100644 --- a/encode.go +++ b/encode.go @@ -478,7 +478,7 @@ func (e *EncodeSession) handleStderrLine(line string) { _, err := fmt.Sscanf(line, "size=%dkB time=%d:%d:%f bitrate=%fkbits/s speed=%fx", &size, &timeH, &timeM, &timeS, &bitrate, &speed) if err != nil { - logln("Error parsing ffmpeg stats:", err) + //logln("Error parsing ffmpeg stats:", err) } dur := time.Duration(timeH) * time.Hour