Compare commits
3 commits
convert-go
...
mistress
| Author | SHA1 | Date | |
|---|---|---|---|
| 31e91a0fa1 | |||
| 56cfdb5e17 | |||
| 474ae1479c |
2 changed files with 10 additions and 4 deletions
6
main.go
6
main.go
|
|
@ -74,6 +74,7 @@ type WD14Caption struct {
|
||||||
var (
|
var (
|
||||||
config *Config
|
config *Config
|
||||||
httpClient = &http.Client{}
|
httpClient = &http.Client{}
|
||||||
|
videoSem = make(chan struct{}, 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
func loadConfig() (*Config, error) {
|
func loadConfig() (*Config, error) {
|
||||||
|
|
@ -294,6 +295,11 @@ func handleImage(w http.ResponseWriter, data []byte, fileName, contentType, thre
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleVideo(w http.ResponseWriter, data []byte, fileName, threshold string) {
|
func handleVideo(w http.ResponseWriter, data []byte, fileName, threshold string) {
|
||||||
|
slog.Info("waiting for video processing slot", "queued", len(videoSem))
|
||||||
|
videoSem <- struct{}{}
|
||||||
|
defer func() { <-videoSem }()
|
||||||
|
slog.Info("acquired video processing slot")
|
||||||
|
|
||||||
// Write video to temp file
|
// Write video to temp file
|
||||||
ext := filepath.Ext(fileName)
|
ext := filepath.Ext(fileName)
|
||||||
tmpFile, err := os.CreateTemp("", "glimbus-video-*"+ext)
|
tmpFile, err := os.CreateTemp("", "glimbus-video-*"+ext)
|
||||||
|
|
|
||||||
8
video.go
8
video.go
|
|
@ -198,14 +198,14 @@ func getFrameSkipSeconds(totalSeconds int) int {
|
||||||
case totalSeconds <= 60:
|
case totalSeconds <= 60:
|
||||||
return 5
|
return 5
|
||||||
case totalSeconds <= 120:
|
case totalSeconds <= 120:
|
||||||
return 10
|
return 7
|
||||||
case totalSeconds <= 300:
|
case totalSeconds <= 300:
|
||||||
return 12
|
return 10
|
||||||
case totalSeconds <= 1000:
|
case totalSeconds <= 1000:
|
||||||
return 15
|
return 15
|
||||||
case totalSeconds <= 1200:
|
case totalSeconds <= 1200:
|
||||||
return 40
|
return 20
|
||||||
default:
|
default:
|
||||||
return 60
|
return 26
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue