Merged in audio-meta-addition (pull request #275)

revid: audio input meta additions moved to Revid.setupPipeline()

Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
Saxon Milton 2019-11-09 21:57:58 +00:00
commit d07be12648
2 changed files with 12 additions and 16 deletions

View File

@ -19,12 +19,8 @@ LICENSE
package revid package revid
import ( import (
"fmt"
"strconv"
"time" "time"
"bitbucket.org/ausocean/av/codec/codecutil"
"bitbucket.org/ausocean/av/container/mts"
"bitbucket.org/ausocean/av/input/audio" "bitbucket.org/ausocean/av/input/audio"
"bitbucket.org/ausocean/utils/logger" "bitbucket.org/ausocean/utils/logger"
) )
@ -40,18 +36,6 @@ func (r *Revid) startAudioDevice() (func() error, error) {
BitDepth: r.cfg.BitDepth, BitDepth: r.cfg.BitDepth,
Codec: r.cfg.InputCodec, Codec: r.cfg.InputCodec,
} }
mts.Meta.Add("sampleRate", strconv.Itoa(r.cfg.SampleRate))
mts.Meta.Add("channels", strconv.Itoa(r.cfg.Channels))
mts.Meta.Add("period", fmt.Sprintf("%.6f", r.cfg.RecPeriod))
mts.Meta.Add("bitDepth", strconv.Itoa(r.cfg.BitDepth))
switch r.cfg.InputCodec {
case codecutil.PCM:
mts.Meta.Add("codec", "pcm")
case codecutil.ADPCM:
mts.Meta.Add("codec", "adpcm")
default:
r.cfg.Logger.Log(logger.Fatal, pkg+"no audio codec set in config")
}
ai, err := audio.NewDevice(ac, r.cfg.Logger) ai, err := audio.NewDevice(ac, r.cfg.Logger)
if err != nil { if err != nil {

View File

@ -337,6 +337,18 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
panic("not implemented") panic("not implemented")
} }
case config.InputAudio: case config.InputAudio:
mts.Meta.Add("sampleRate", strconv.Itoa(r.cfg.SampleRate))
mts.Meta.Add("channels", strconv.Itoa(r.cfg.Channels))
mts.Meta.Add("period", fmt.Sprintf("%.6f", r.cfg.RecPeriod))
mts.Meta.Add("bitDepth", strconv.Itoa(r.cfg.BitDepth))
switch r.cfg.InputCodec {
case codecutil.PCM:
mts.Meta.Add("codec", "pcm")
case codecutil.ADPCM:
mts.Meta.Add("codec", "adpcm")
default:
r.cfg.Logger.Log(logger.Fatal, pkg+"no audio codec set in config")
}
r.setupInput = r.startAudioDevice r.setupInput = r.startAudioDevice
r.lexTo = codecutil.NewByteLexer(&r.cfg.ChunkSize).Lex r.lexTo = codecutil.NewByteLexer(&r.cfg.ChunkSize).Lex
} }