revid/config.go: MinPeriod => MinFrames

This commit is contained in:
Saxon 2019-08-26 13:43:45 +09:30
parent e57e14678a
commit a8081b52b2
2 changed files with 14 additions and 14 deletions

View File

@ -109,7 +109,7 @@ const (
defaultRotation = 0 // Degrees defaultRotation = 0 // Degrees
defaultWidth = 1280 defaultWidth = 1280
defaultHeight = 720 defaultHeight = 720
defaultMinPeriod = 100 defaultMinFrames = 100
defaultClipDuration = 0 defaultClipDuration = 0
defaultQuantization = 30 defaultQuantization = 30
defaultBitrate = 400000 defaultBitrate = 400000
@ -204,14 +204,14 @@ type Config struct {
// are using Raspivid input. // are using Raspivid input.
Quantization uint Quantization uint
// MinPeriod defines the frequency of key NAL units SPS, PPS and IDR in // MinFrames defines the frequency of key NAL units SPS, PPS and IDR in
// number of NAL units. This will also determine the frequency of PSI if the // number of NAL units. This will also determine the frequency of PSI if the
// output container is MPEG-TS. If ClipDuration is less than MinPeriod, // output container is MPEG-TS. If ClipDuration is less than MinFrames,
// ClipDuration will default to MinPeriod. // ClipDuration will default to MinFrames.
MinPeriod uint MinFrames uint
// ClipDuration is the duration of MTS data that is sent using HTTP or RTP // ClipDuration is the duration of MTS data that is sent using HTTP or RTP
// output. This defaults to 0, therefore MinPeriod will determine the length of // output. This defaults to 0, therefore MinFrames will determine the length of
// clips by default. // clips by default.
ClipDuration time.Duration ClipDuration time.Duration
@ -392,10 +392,10 @@ func (c *Config) Validate() error {
return errors.New("invalid bitrate") return errors.New("invalid bitrate")
} }
if c.MinPeriod == 0 { if c.MinFrames == 0 {
c.Logger.Log(logger.Info, pkg+"no min period defined, defaulting", "MinPeriod", defaultMinPeriod) c.Logger.Log(logger.Info, pkg+"no min period defined, defaulting", "MinFrames", defaultMinFrames)
c.MinPeriod = defaultMinPeriod c.MinFrames = defaultMinFrames
} else if c.MinPeriod < 0 { } else if c.MinFrames < 0 {
return errors.New("refresh period is less than 0") return errors.New("refresh period is less than 0")
} }

View File

@ -456,13 +456,13 @@ func (r *Revid) Update(vars map[string]string) error {
break break
} }
r.config.Quantization = uint(v) r.config.Quantization = uint(v)
case "MinPeriod": case "MinFrames":
v, err := strconv.Atoi(value) v, err := strconv.Atoi(value)
if err != nil { if err != nil {
r.config.Logger.Log(logger.Warning, pkg+"invalid MinPeriod param", "value", value) r.config.Logger.Log(logger.Warning, pkg+"invalid MinFrames param", "value", value)
break break
} }
r.config.MinPeriod = uint(v) r.config.MinFrames = uint(v)
case "ClipDuration": case "ClipDuration":
v, err := strconv.Atoi(value) v, err := strconv.Atoi(value)
@ -585,7 +585,7 @@ func (r *Revid) startRaspivid() (func() error, error) {
args = append(args, args = append(args,
"--codec", "H264", "--codec", "H264",
"--inline", "--inline",
"--intra", fmt.Sprint(r.config.MinPeriod), "--intra", fmt.Sprint(r.config.MinFrames),
) )
if r.config.Quantization != 0 { if r.config.Quantization != 0 {
args = append(args, "-qp", fmt.Sprint(r.config.Quantization)) args = append(args, "-qp", fmt.Sprint(r.config.Quantization))