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:
go build .
install: build
sudo cp vidcrunch /usr/local/bin/

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

@ -31,7 +31,8 @@ type VideoOpts struct {
type Settings struct {
Debug int
Force bool
Server string
Serve string
Port string
ConfigPath string
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.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.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()
}

@ -7,6 +7,7 @@ import (
"log"
"os"
"math/rand"
"net/http"
"strings"
"lcthw.dev/go/vidcrunch/config"
"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 {
encode.InputOptions(
"-ss", fmt.Sprintf("00:%d", encoding.TestStart))
encode.InputOptions("-ss", fmt.Sprintf("00:%d", encoding.TestStart))
extras = append(extras, "-t", fmt.Sprint(encoding.Test))
}
@ -118,6 +118,16 @@ func RenderToDir(encoding config.VideoOpts, force bool) {
func main() {
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 {
if encoding.OutDir != "" {
RenderToDir(encoding, settings.Force)
@ -125,4 +135,5 @@ func main() {
log.Fatal("config file needs either Output or OutDir")
}
}
}
}

Loading…
Cancel
Save