forked from pion/mediadevices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.go
50 lines (42 loc) · 1.09 KB
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package x264
import (
"github.com/carbonrobotics/mediadevices/pkg/codec"
"github.com/carbonrobotics/mediadevices/pkg/io/video"
"github.com/carbonrobotics/mediadevices/pkg/prop"
)
// Params stores libx264 specific encoding parameters.
type Params struct {
codec.BaseParams
// Faster preset has lower CPU usage but lower quality
Preset Preset
}
// Preset represents a set of default configurations from libx264
type Preset int
const (
PresetUltrafast Preset = iota
PresetSuperfast
PresetVeryfast
PresetFaster
PresetFast
PresetMedium
PresetSlow
PresetSlower
PresetVeryslow
PresetPlacebo
)
// NewParams returns default x264 codec specific parameters.
func NewParams() (Params, error) {
return Params{
BaseParams: codec.BaseParams{
KeyFrameInterval: 60,
},
}, nil
}
// RTPCodec represents the codec metadata
func (p *Params) RTPCodec() *codec.RTPCodec {
return codec.NewRTPH264Codec(90000)
}
// BuildVideoEncoder builds x264 encoder with given params
func (p *Params) BuildVideoEncoder(r video.Reader, property prop.Media) (codec.ReadCloser, error) {
return newEncoder(r, property, *p)
}