Added a -serve and -port option to do a quick webserver for testing.

master
Zed A. Shaw 1 month ago
parent ff20dd1137
commit 9d87143a95
  1. 9
      Makefile
  2. 31
      config.json
  3. 6
      config/settings.go
  4. 15
      main.go

@ -1,8 +1,5 @@
GO_IS_STUPID_EXE=
ifeq '$(OS)' 'Windows_NT'
GO_IS_STUPID_EXE=.exe
endif
build: build:
go build . go build .
install: build
sudo cp vidcrunch /usr/local/bin/

@ -6,9 +6,8 @@
"VideoBitrate": 900, "VideoBitrate": 900,
"AudioBitrate": 192, "AudioBitrate": 192,
"VideoCodec": "libvpx-vp9", "VideoCodec": "libvpx-vp9",
"Preset": "veryfast",
"CleanFilename": false, "CleanFilename": false,
"CRF": 30, "CRF": 20,
"FPS": 30, "FPS": 30,
"Tune": "animation", "Tune": "animation",
"Input": "LGo*.mp4", "Input": "LGo*.mp4",
@ -17,27 +16,13 @@
"Extras": [ "Extras": [
"-deadline", "realtime", "-deadline", "realtime",
"-row-mt", "1", "-row-mt", "1",
"-cpu-used", "8" "-cpu-used", "8",
] "-g", "150",
}, "-keyint_min", "150",
{ "-tile-columns", "4",
"Format": "webm", "-tile-rows", "2",
"VideoCodec": "libvpx-vp9", "-frame-parallel", "1",
"Scale": "1280:720", "-tune-content", "1"
"Resize": false,
"VideoBitrate": 600,
"AudioBitrate": 192,
"CleanFilename": false,
"CRF": 30,
"FPS": 30,
"Tune": "animation",
"Input": "LGo*.mp4",
"OutDir": "dash_test",
"Passes": 1,
"Extras": [
"-deadline", "realtime",
"-row-mt", "1",
"-cpu-used", "8"
] ]
} }
] ]

@ -31,7 +31,8 @@ type VideoOpts struct {
type Settings struct { type Settings struct {
Debug int Debug int
Force bool Force bool
Server string Serve string
Port string
ConfigPath string ConfigPath string
Encodings []VideoOpts Encodings []VideoOpts
} }
@ -40,7 +41,8 @@ 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.Force, "force", false, "Force the render even if the file exists.") 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.StringVar(&c.Server, "server", ":8099", "start a simple HTTP server for testing") flag.StringVar(&c.Serve, "serve", "", "serve a directory webserver")
flag.StringVar(&c.Port, "port", ":8099", "start a simple HTTP server for testing")
flag.Parse() flag.Parse()
} }

@ -7,6 +7,7 @@ import (
"log" "log"
"os" "os"
"math/rand" "math/rand"
"net/http"
"strings" "strings"
"lcthw.dev/go/vidcrunch/config" "lcthw.dev/go/vidcrunch/config"
"github.com/modfy/fluent-ffmpeg" "github.com/modfy/fluent-ffmpeg"
@ -53,8 +54,7 @@ func Run(encoding config.VideoOpts, pass int, pid int, input string, output stri
} }
if encoding.Test > 0 { if encoding.Test > 0 {
encode.InputOptions( encode.InputOptions("-ss", fmt.Sprintf("00:%d", encoding.TestStart))
"-ss", fmt.Sprintf("00:%d", encoding.TestStart))
extras = append(extras, "-t", fmt.Sprint(encoding.Test)) extras = append(extras, "-t", fmt.Sprint(encoding.Test))
} }
@ -118,6 +118,16 @@ func RenderToDir(encoding config.VideoOpts, force bool) {
func main() { func main() {
settings := config.Load() settings := config.Load()
if settings.Serve != "" {
dir_handler := http.FileServer(http.Dir(settings.Serve))
http.HandleFunc("/", func (w http.ResponseWriter, r *http.Request) {
fmt.Println(r.Method, r.URL)
dir_handler.ServeHTTP(w, r)
})
log.Fatal(http.ListenAndServe(settings.Port, nil))
} else {
for _, encoding := range settings.Encodings { for _, encoding := range settings.Encodings {
if encoding.OutDir != "" { if encoding.OutDir != "" {
RenderToDir(encoding, settings.Force) RenderToDir(encoding, settings.Force)
@ -125,4 +135,5 @@ func main() {
log.Fatal("config file needs either Output or OutDir") log.Fatal("config file needs either Output or OutDir")
} }
} }
}
} }

Loading…
Cancel
Save