Fixes a few things to make testing encoding quicker.

master
Zed A. Shaw 1 month ago
parent f92a8243e8
commit bb51688a6a
  1. 66
      config.json
  2. 6
      config/settings.go
  3. 11
      main.go

@ -1,18 +1,19 @@
[
{
"Format": "mp4",
"Scale": "1280:720",
"Resize": true,
"Scale": "1920:1080",
"Resize": false,
"VideoBitrate": 900,
"AudioBitrate": 192,
"Speed": "veryfast",
"VideoCodec": "libx264",
"Preset": "veryfast",
"CleanFilename": false,
"CRF": 20,
"CRF": 30,
"FPS": 30,
"Tune": "animation",
"Input": "*.mp4",
"OutDir": "renders",
"Passes": 3,
"Input": "LGo*.mp4",
"OutDir": "mp4_test",
"Passes": 1,
"Extras": [
"-movflags", "faststart",
"-tune", "animation"
@ -20,59 +21,22 @@
},
{
"Format": "webm",
"VideoBitrate": 600,
"Scale": "1280:720",
"Resize": true,
"VideoCodec": "libvpx-vp9",
"AudioBitrate": 192,
"AudioCodec": "libopus",
"Speed": "veryfast",
"CleanFilename": false,
"CRF": 20,
"FPS": 30,
"Tune": "animation",
"Input": "*.mp4",
"OutDir": "renders",
"Passes": 2,
"Extras": [
]
},
{
"Format": "mp4",
"Scale": "1920:1080",
"Resize": false,
"VideoBitrate": 900,
"AudioBitrate": 192,
"Speed": "veryfast",
"CleanFilename": false,
"CRF": 20,
"CRF": 30,
"FPS": 30,
"Tune": "animation",
"Input": "*.mp4",
"OutDir": "renders",
"Passes": 3,
"Input": "LGo*.mp4",
"OutDir": "webm_test",
"Passes": 1,
"Extras": [
"-movflags", "faststart",
"-tune", "animation"
"-deadline", "realtime",
"-row-mt", "1",
"-cpu-used", "8"
]
},
{
"Format": "webm",
"Scale": "1920:1080",
"Resize": false,
"VideoBitrate": 600,
"VideoCodec": "libvpx-vp9",
"AudioBitrate": 192,
"AudioCodec": "libopus",
"Speed": "veryfast",
"CleanFilename": false,
"CRF": 20,
"FPS": 30,
"Tune": "animation",
"Input": "*.mp4",
"OutDir": "renders",
"Passes": 2,
"Extras": [
]
}
]

@ -15,7 +15,7 @@ type VideoOpts struct {
VideoCodec string
AudioBitrate int
AudioCodec string
Speed string
Preset string
CleanFilename bool
CRF int
FPS int
@ -30,14 +30,14 @@ type VideoOpts struct {
type Settings struct {
Debug int
Progress bool
Force 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.BoolVar(&c.Force, "force", false, "Force the render even if the file exists.")
flag.StringVar(&c.ConfigPath, "config", "config.json", "config.json to load")
flag.Parse()

@ -33,7 +33,10 @@ func Run(encoding config.VideoOpts, pass int, pid int, input string, output stri
"-pix_fmt", "yuv420p",
"-pass", fmt.Sprint(pass),
"-passlogfile", fmt.Sprintf("ffmpeg2pass-%x.log", pid),
"-preset", encoding.Speed,
}
if encoding.Preset != "" {
extras = append(extras, "-preset", encoding.Preset)
}
if encoding.Resize {
@ -94,7 +97,7 @@ func RenderFile(encoding config.VideoOpts, pid int, path string, target string)
Run(encoding, encoding.Passes, pid, path, target)
}
func RenderToDir(encoding config.VideoOpts) {
func RenderToDir(encoding config.VideoOpts, force bool) {
matches, err := filepath.Glob(encoding.Input)
if err != nil { log.Fatalf("%v", err) }
@ -105,7 +108,7 @@ func RenderToDir(encoding config.VideoOpts) {
_, err := os.Stat(target)
if err != nil {
if err != nil || force {
fmt.Println("--- PATH", path, "->", target)
RenderFile(encoding, rand.Int(), path, target)
} else {
@ -119,7 +122,7 @@ func main() {
for _, encoding := range settings.Encodings {
if encoding.OutDir != "" {
RenderToDir(encoding)
RenderToDir(encoding, settings.Force)
} else {
log.Fatal("config file needs either Output or OutDir")
}

Loading…
Cancel
Save