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
|
//go:generate rice embed-go
|
||||||
|
|
||||||
var (
|
|
||||||
SizeMap = map[string]string{
|
|
||||||
"hd720": "720p",
|
|
||||||
"hd480": "480p",
|
|
||||||
"nhd": "360p",
|
|
||||||
"film": "240p",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// App represents main application.
|
// App represents main application.
|
||||||
type App struct {
|
type App struct {
|
||||||
Config *Config
|
Config *Config
|
||||||
|
@ -327,7 +318,7 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// TODO: Make this a background job
|
// TODO: Make this a background job
|
||||||
// Resize for lower quality options
|
// Resize for lower quality options
|
||||||
for size, suffix := range SizeMap {
|
for size, suffix := range a.Config.Transcoder.Sizes {
|
||||||
log.
|
log.
|
||||||
WithField("size", size).
|
WithField("size", size).
|
||||||
WithField("vf", filepath.Base(vf)).
|
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
|
// TODO: Make this a background job
|
||||||
// Resize for lower quality options
|
// Resize for lower quality options
|
||||||
for size, suffix := range SizeMap {
|
for size, suffix := range a.Config.Transcoder.Sizes {
|
||||||
log.
|
log.
|
||||||
WithField("size", size).
|
WithField("size", size).
|
||||||
WithField("vf", filepath.Base(vf)).
|
WithField("vf", filepath.Base(vf)).
|
||||||
|
|
|
@ -34,9 +34,13 @@ type ThumbnailerConfig struct {
|
||||||
Timeout int `json:"timeout"`
|
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
|
// TranscoderConfig settings for Transcoder
|
||||||
type TranscoderConfig struct {
|
type TranscoderConfig struct {
|
||||||
Timeout int `json:"timeout"`
|
Timeout int `json:"timeout"`
|
||||||
|
Sizes Sizes `json:"sizes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FeedConfig settings for App Feed.
|
// FeedConfig settings for App Feed.
|
||||||
|
@ -73,6 +77,7 @@ func DefaultConfig() *Config {
|
||||||
},
|
},
|
||||||
Transcoder: &TranscoderConfig{
|
Transcoder: &TranscoderConfig{
|
||||||
Timeout: 300,
|
Timeout: 300,
|
||||||
|
Sizes: Sizes(nil),
|
||||||
},
|
},
|
||||||
Feed: &FeedConfig{
|
Feed: &FeedConfig{
|
||||||
ExternalURL: "http://localhost:8000",
|
ExternalURL: "http://localhost:8000",
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,8 @@
|
||||||
"timeout": 60
|
"timeout": 60
|
||||||
},
|
},
|
||||||
"transcoder": {
|
"transcoder": {
|
||||||
"timeout": 300
|
"timeout": 300,
|
||||||
|
"sizes": null
|
||||||
},
|
},
|
||||||
"feed": {
|
"feed": {
|
||||||
"external_url": "",
|
"external_url": "",
|
||||||
|
|
Loading…
Reference in a new issue