Allow transcoding to smaller sizes a configurable and optional feature
This commit is contained in:
parent
7c919b5f9b
commit
cd574192bf
4 changed files with 27 additions and 30 deletions
13
app/app.go
13
app/app.go
|
@ -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)).
|
||||
|
|
|
@ -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
|
@ -16,7 +16,8 @@
|
|||
"timeout": 60
|
||||
},
|
||||
"transcoder": {
|
||||
"timeout": 300
|
||||
"timeout": 300,
|
||||
"sizes": null
|
||||
},
|
||||
"feed": {
|
||||
"external_url": "",
|
||||
|
|
Loading…
Reference in a new issue