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

57 lines
1.0 KiB

package config
import (
"flag"
"log"
"os"
"encoding/json"
)
type VideoOpts struct {
Scale string
VideoBitrate int
AudioBitrate int
Speed string
CleanFilename bool
CRF int
FPS int
Tune string
Input string
OutDir string
Test int
TestStart int
}
type Settings struct {
Debug int
Progress bool
ConfigPath string
Encodings []VideoOpts
}
func ParseFlags(c *Settings) {
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.json", "config.json to load")
flag.Parse()
}
func Load() Settings {
var config Settings
ParseFlags(&config)
data, err := os.ReadFile(config.ConfigPath)
if err != nil {
log.Fatalf("error reading config %s: %v", config.ConfigPath, err);
}
err = json.Unmarshal(data, &config.Encodings)
if err != nil {
log.Fatalf("error loading %s: %v", config.ConfigPath, err)
}
return config
}