A simple little command line tool in Go to crunch my videos. This includes many settings I've found that compress "code videos" really well. YMMV.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
vidcrunch/config/settings.go

56 lines
1.2 KiB

package config
import (
"flag"
"log"
"github.com/BurntSushi/toml"
)
type config struct {
Test int
TestStart int
InitOutdir bool
Debug int
Progress bool
ConfigPath string
Scale string
VideoBitrate int
AudioBitrate int
Speed string
CleanFilename bool
CRF int
FPS int
Tune string
Input string
Output string
}
var Settings config
func parseFlags(c *config) {
flag.IntVar(&c.Test, "test", 0, "Make a test video <int> seconds long.")
flag.IntVar(&c.TestStart, "test-start", 60, "When to start the test clip.")
flag.BoolVar(&c.InitOutdir, "init-outdir", false, "if outdir doesn't exist create it")
flag.IntVar(&c.Debug, "debug", 0, "1=print the ffmpeg command, 2=and its stderr output")
flag.BoolVar(&c.Progress, "progress", false, "Show percent progress. Not accurate (thanks ffmpeg)")
flag.StringVar(&c.ConfigPath, "config", "config.toml", "config.toml to load")
flag.Parse()
}
func Load() {
parseFlags(&Settings)
metadata, err := toml.DecodeFile(Settings.ConfigPath, &Settings)
if err != nil {
log.Fatalf("error loading config.toml: %v", err)
}
bad_keys := metadata.Undecoded()
if len(bad_keys) > 0 {
log.Fatalf("unknown configuration keys: %v", bad_keys);
}
}