add: run video in pipe
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// Package config handles loading the config.
|
||||
package config
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
var Default *Mod
|
||||
|
||||
type Cmd struct {
|
||||
Binary string
|
||||
Arguments []string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
H264Cmd *Cmd `yaml:"h264"`
|
||||
IVFCmd *Cmd `yaml:"ivf"`
|
||||
}
|
||||
|
||||
func New(source []byte) (*Config, error) {
|
||||
config := &Config{}
|
||||
if err := yaml.Unmarshal(source, config); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse config: %w", err)
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
type Mod struct {
|
||||
filePath string
|
||||
}
|
||||
|
||||
func (m *Mod) RegisterFlags(fs *flag.FlagSet) {
|
||||
fs.StringVar(&m.filePath, "watcher_config", "", "path to the watcher configuration")
|
||||
}
|
||||
|
||||
func (m *Mod) Get() (*Config, error) {
|
||||
bytes, err := os.ReadFile(m.filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read file %q: %w", m.filePath, err)
|
||||
}
|
||||
|
||||
config, err := New(bytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
Default = &Mod{}
|
||||
Default.RegisterFlags(flag.CommandLine)
|
||||
}
|
||||
Reference in New Issue
Block a user