mirror of https://bitbucket.org/ausocean/av.git
revid: revid building and running with audio additions
This commit is contained in:
parent
889d440259
commit
3484e35692
|
@ -127,7 +127,6 @@ func handleFlags() revid.Config {
|
|||
heightPtr = flag.Uint("Height", 0, "Height in pixels")
|
||||
widthPtr = flag.Uint("Width", 0, "Width in pixels")
|
||||
frameRatePtr = flag.Uint("FrameRate", 0, "Frame rate of captured video")
|
||||
sampleRatePtr = flag.Uint("SampleRate", 0, "Sample rate of recorded audio")
|
||||
quantizationPtr = flag.Uint("Quantization", 0, "Desired quantization value: 0-40")
|
||||
intraRefreshPeriodPtr = flag.Uint("IntraRefreshPeriod", 0, "The IntraRefreshPeriod i.e. how many keyframes we send")
|
||||
rotationPtr = flag.Uint("Rotation", 0, "Rotate video output. (0-359 degrees)")
|
||||
|
@ -135,6 +134,10 @@ func handleFlags() revid.Config {
|
|||
saturationPtr = flag.Int("Saturation", 0, "Set Saturation. (100-100)")
|
||||
exposurePtr = flag.String("Exposure", "auto", "Set exposure mode. ("+strings.Join(revid.ExposureModes[:], ",")+")")
|
||||
autoWhiteBalancePtr = flag.String("Awb", "auto", "Set automatic white balance mode. ("+strings.Join(revid.AutoWhiteBalanceModes[:], ",")+")")
|
||||
sampleRatePtr = flag.Int("SampleRate", 48000, "Sample rate of recorded audio")
|
||||
channelsPtr = flag.Int("Channels", 1, "Record in Mono or Stereo (1 or 2)")
|
||||
recPeriodPtr = flag.Int("recPeriod", 5, "How many seconds to record at a time")
|
||||
bitDepthPtr = flag.Int("bitDepth", 16, "Bit Depth to record audio at.")
|
||||
)
|
||||
|
||||
var outputs flagStrings
|
||||
|
@ -192,9 +195,9 @@ func handleFlags() revid.Config {
|
|||
|
||||
switch *inputPtr {
|
||||
case "Audio":
|
||||
cfg.Rate = float64(*sampleRatePtr*sampleSize) / float64(blockSize)
|
||||
cfg.WriteRate = float64(*sampleRatePtr*sampleSize) / float64(blockSize)
|
||||
default:
|
||||
cfg.Rate = float64(*frameRatePtr)
|
||||
cfg.WriteRate = float64(*frameRatePtr)
|
||||
}
|
||||
|
||||
switch *inputCodecPtr {
|
||||
|
@ -255,7 +258,6 @@ func handleFlags() revid.Config {
|
|||
cfg.Height = *heightPtr
|
||||
cfg.Width = *widthPtr
|
||||
cfg.FrameRate = *frameRatePtr
|
||||
cfg.SampleRate = *sampleRatePtr
|
||||
cfg.HttpAddress = *httpAddressPtr
|
||||
cfg.Quantization = *quantizationPtr
|
||||
cfg.IntraRefreshPeriod = *intraRefreshPeriodPtr
|
||||
|
@ -265,6 +267,10 @@ func handleFlags() revid.Config {
|
|||
cfg.Saturation = *saturationPtr
|
||||
cfg.Exposure = *exposurePtr
|
||||
cfg.AutoWhiteBalance = *autoWhiteBalancePtr
|
||||
cfg.SampleRate = *sampleRatePtr
|
||||
cfg.Channels = *channelsPtr
|
||||
cfg.RecPeriod = *recPeriodPtr
|
||||
cfg.BitDepth = *bitDepthPtr
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ type Config struct {
|
|||
|
||||
// Audio
|
||||
SampleRate int // Samples a second (Hz).
|
||||
Period int // How many seconds to record at a time.
|
||||
RecPeriod int // How many seconds to record at a time.
|
||||
Channels int // Number of audio channels, 1 for mono, 2 for stereo.
|
||||
BitDepth int // Sample bit depth.
|
||||
}
|
||||
|
@ -147,7 +147,6 @@ const (
|
|||
defaultOutput = Http
|
||||
defaultPacketization = Flv
|
||||
defaultFrameRate = 25
|
||||
defaultSampleRate = 48000
|
||||
defaultWriteRate = 25
|
||||
defaultWidth = 1280
|
||||
defaultHeight = 720
|
||||
|
@ -166,6 +165,11 @@ const (
|
|||
defaultBrightness = 50
|
||||
defaultExposure = "auto"
|
||||
defaultAutoWhiteBalance = "auto"
|
||||
|
||||
defaultSampleRate = 48000
|
||||
defaultBitDepth = 16
|
||||
defaultChannels = 1
|
||||
defaultRecPeriod = 5
|
||||
)
|
||||
|
||||
// Validate checks for any errors in the config fields and defaults settings
|
||||
|
@ -208,7 +212,7 @@ func (c *Config) Validate(r *Revid) error {
|
|||
if c.Quantization > 0 || c.Bitrate == 0 {
|
||||
return errors.New("bad bitrate or quantization for mjpeg input")
|
||||
}
|
||||
|
||||
case PCM, ADPCM:
|
||||
case NothingDefined:
|
||||
c.Logger.Log(logger.Info, pkg+"no input codec defined, defaulting",
|
||||
"inputCodec", defaultInputCodec)
|
||||
|
|
|
@ -254,6 +254,8 @@ func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.Writer, rate int) (io.W
|
|||
r.setupInput = r.startV4L
|
||||
case File:
|
||||
r.setupInput = r.setupInputForFile
|
||||
case Audio:
|
||||
r.setupInput = r.startAudioInput
|
||||
}
|
||||
|
||||
switch r.config.InputCodec {
|
||||
|
@ -678,7 +680,7 @@ func (r *Revid) setupInputForFile() error {
|
|||
func (r *Revid) startAudioInput() error {
|
||||
ai := NewAudioInput(&r.config)
|
||||
|
||||
go r.processFrom(ai, time.Second/time.Duration(r.config.Rate))
|
||||
go r.processFrom(ai, time.Second/time.Duration(r.config.WriteRate))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue