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", "Format": "mp4",
"Scale": "1280:720", "Scale": "1920:1080",
"Resize": true, "Resize": false,
"VideoBitrate": 900, "VideoBitrate": 900,
"AudioBitrate": 192, "AudioBitrate": 192,
"Speed": "veryfast", "VideoCodec": "libx264",
"Preset": "veryfast",
"CleanFilename": false, "CleanFilename": false,
"CRF": 20, "CRF": 30,
"FPS": 30, "FPS": 30,
"Tune": "animation", "Tune": "animation",
"Input": "*.mp4", "Input": "LGo*.mp4",
"OutDir": "renders", "OutDir": "mp4_test",
"Passes": 3, "Passes": 1,
"Extras": [ "Extras": [
"-movflags", "faststart", "-movflags", "faststart",
"-tune", "animation" "-tune", "animation"
@ -20,59 +21,22 @@
}, },
{ {
"Format": "webm", "Format": "webm",
"VideoBitrate": 600,
"Scale": "1280:720",
"Resize": true,
"VideoCodec": "libvpx-vp9", "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", "Scale": "1920:1080",
"Resize": false, "Resize": false,
"VideoBitrate": 900, "VideoBitrate": 900,
"AudioBitrate": 192, "AudioBitrate": 192,
"Speed": "veryfast",
"CleanFilename": false, "CleanFilename": false,
"CRF": 20, "CRF": 30,
"FPS": 30, "FPS": 30,
"Tune": "animation", "Tune": "animation",
"Input": "*.mp4", "Input": "LGo*.mp4",
"OutDir": "renders", "OutDir": "webm_test",
"Passes": 3, "Passes": 1,
"Extras": [ "Extras": [
"-movflags", "faststart", "-deadline", "realtime",
"-tune", "animation" "-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 VideoCodec string
AudioBitrate int AudioBitrate int
AudioCodec string AudioCodec string
Speed string Preset string
CleanFilename bool CleanFilename bool
CRF int CRF int
FPS int FPS int
@ -30,14 +30,14 @@ type VideoOpts struct {
type Settings struct { type Settings struct {
Debug int Debug int
Progress bool Force bool
ConfigPath string ConfigPath string
Encodings []VideoOpts Encodings []VideoOpts
} }
func ParseFlags(c *Settings) { func ParseFlags(c *Settings) {
flag.IntVar(&c.Debug, "debug", 0, "1=print the ffmpeg command, 2=and its stderr output") 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.StringVar(&c.ConfigPath, "config", "config.json", "config.json to load")
flag.Parse() flag.Parse()

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

Loading…
Cancel
Save