diff --git a/encode.go b/encode.go index 640e26b..3df974c 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) @@ -65,8 +65,9 @@ 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.Volume < 0 || opts.Volume > 2 { + return errors.New("Out of bounds volume (0-2)") } if opts.FrameDuration != 20 && opts.FrameDuration != 40 && opts.FrameDuration != 60 { @@ -94,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, @@ -212,7 +213,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), @@ -221,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 != "" { @@ -477,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