Allow transcoding to smaller sizes a configurable and optional feature

This commit is contained in:
James Mills 2020-03-31 19:04:21 +10:00
parent 7c919b5f9b
commit cd574192bf
No known key found for this signature in database
GPG key ID: AC4C014F1440EBD6
4 changed files with 27 additions and 30 deletions

View file

@ -28,15 +28,6 @@ import (
//go:generate rice embed-go
var (
SizeMap = map[string]string{
"hd720": "720p",
"hd480": "480p",
"nhd": "360p",
"film": "240p",
}
)
// App represents main application.
type App struct {
Config *Config
@ -327,7 +318,7 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
// TODO: Make this a background job
// Resize for lower quality options
for size, suffix := range SizeMap {
for size, suffix := range a.Config.Transcoder.Sizes {
log.
WithField("size", size).
WithField("vf", filepath.Base(vf)).
@ -518,7 +509,7 @@ func (a *App) importHandler(w http.ResponseWriter, r *http.Request) {
// TODO: Make this a background job
// Resize for lower quality options
for size, suffix := range SizeMap {
for size, suffix := range a.Config.Transcoder.Sizes {
log.
WithField("size", size).
WithField("vf", filepath.Base(vf)).

View file

@ -34,9 +34,13 @@ type ThumbnailerConfig struct {
Timeout int `json:"timeout"`
}
// Sizes a map of ffmpeg -s option to suffix. e.g: hd720 -> #720p
type Sizes map[string]string
// TranscoderConfig settings for Transcoder
type TranscoderConfig struct {
Timeout int `json:"timeout"`
Timeout int `json:"timeout"`
Sizes Sizes `json:"sizes"`
}
// FeedConfig settings for App Feed.
@ -73,6 +77,7 @@ func DefaultConfig() *Config {
},
Transcoder: &TranscoderConfig{
Timeout: 300,
Sizes: Sizes(nil),
},
Feed: &FeedConfig{
ExternalURL: "http://localhost:8000",

File diff suppressed because one or more lines are too long

View file

@ -16,7 +16,8 @@
"timeout": 60
},
"transcoder": {
"timeout": 300
"timeout": 300,
"sizes": null
},
"feed": {
"external_url": "",