mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Remove x-route header and use a env var instead
This commit is contained in:
parent
da0f415ecf
commit
2eecb5174c
@ -7,6 +7,8 @@ x-transcoder: &transcoder-base
|
||||
restart: on-failure
|
||||
env_file:
|
||||
- ./.env
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
volumes:
|
||||
- ${LIBRARY_ROOT}:/video:ro
|
||||
- ${CACHE_ROOT}:/cache
|
||||
@ -95,6 +97,7 @@ services:
|
||||
devices:
|
||||
- capabilities: [gpu]
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=nvidia
|
||||
profiles: ['nvidia']
|
||||
|
||||
@ -103,6 +106,7 @@ services:
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=vaapi
|
||||
- GOCODER_VAAPI_RENDERER=${GOCODER_VAAPI_RENDERER:-/dev/dri/renderD128}
|
||||
profiles: ['vaapi']
|
||||
@ -112,6 +116,7 @@ services:
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=qsv
|
||||
- GOCODER_VAAPI_RENDERER=${GOCODER_VAAPI_RENDERER:-/dev/dri/renderD128}
|
||||
profiles: ['qsv']
|
||||
|
@ -12,6 +12,8 @@ x-transcoder: &transcoder-base
|
||||
cpus: 1
|
||||
env_file:
|
||||
- ./.env
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
volumes:
|
||||
- ./transcoder:/app
|
||||
- ${LIBRARY_ROOT}:/video:ro
|
||||
@ -119,6 +121,7 @@ services:
|
||||
devices:
|
||||
- capabilities: [gpu]
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=nvidia
|
||||
profiles: ['nvidia']
|
||||
|
||||
@ -127,6 +130,7 @@ services:
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=vaapi
|
||||
- GOCODER_VAAPI_RENDERER=${GOCODER_VAAPI_RENDERER:-/dev/dri/renderD128}
|
||||
profiles: ['vaapi']
|
||||
@ -136,6 +140,7 @@ services:
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=qsv
|
||||
- GOCODER_VAAPI_RENDERER=${GOCODER_VAAPI_RENDERER:-/dev/dri/renderD128}
|
||||
profiles: ['qsv']
|
||||
|
@ -7,6 +7,8 @@ x-transcoder: &transcoder-base
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- ./.env
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
volumes:
|
||||
- ${LIBRARY_ROOT}:/video:ro
|
||||
- ${CACHE_ROOT}:/cache
|
||||
@ -94,6 +96,7 @@ services:
|
||||
devices:
|
||||
- capabilities: [gpu]
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=nvidia
|
||||
profiles: ['nvidia']
|
||||
|
||||
@ -102,6 +105,7 @@ services:
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=vaapi
|
||||
- GOCODER_VAAPI_RENDERER=${GOCODER_VAAPI_RENDERER:-/dev/dri/renderD128}
|
||||
profiles: ['vaapi']
|
||||
@ -111,6 +115,7 @@ services:
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
environment:
|
||||
- GOCODER_PREFIX=/video
|
||||
- GOCODER_HWACCEL=qsv
|
||||
- GOCODER_VAAPI_RENDERER=${GOCODER_VAAPI_RENDERER:-/dev/dri/renderD128}
|
||||
profiles: ['qsv']
|
||||
|
@ -68,7 +68,7 @@ export const useScrubber = (url: string) => {
|
||||
ret[i] = {
|
||||
from: parseTs(times[0]),
|
||||
to: parseTs(times[1]),
|
||||
url: imageFn("/video/" + url[0]),
|
||||
url: imageFn(url[0]),
|
||||
x: xywh[0],
|
||||
y: xywh[1],
|
||||
width: xywh[2],
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
var extracted = NewCMap[string, <-chan struct{}]()
|
||||
|
||||
func Extract(path string, sha string, route string) (<-chan struct{}, error) {
|
||||
func Extract(path string, sha string) (<-chan struct{}, error) {
|
||||
ret := make(chan struct{})
|
||||
existing, created := extracted.GetOrSet(sha, ret)
|
||||
if !created {
|
||||
@ -18,7 +18,7 @@ func Extract(path string, sha string, route string) (<-chan struct{}, error) {
|
||||
|
||||
go func() {
|
||||
defer printExecTime("Starting extraction of %s", path)()
|
||||
info, err := GetInfo(path, sha, route)
|
||||
info, err := GetInfo(path, sha)
|
||||
if err != nil {
|
||||
extracted.Remove(sha)
|
||||
close(ret)
|
||||
|
@ -19,7 +19,7 @@ type FileStream struct {
|
||||
audios CMap[int32, *AudioStream]
|
||||
}
|
||||
|
||||
func NewFileStream(path string, sha string, route string) *FileStream {
|
||||
func NewFileStream(path string, sha string) *FileStream {
|
||||
ret := &FileStream{
|
||||
Path: path,
|
||||
Out: fmt.Sprintf("%s/%s", Settings.Outpath, sha),
|
||||
@ -30,7 +30,7 @@ func NewFileStream(path string, sha string, route string) *FileStream {
|
||||
ret.ready.Add(1)
|
||||
go func() {
|
||||
defer ret.ready.Done()
|
||||
info, err := GetInfo(path, sha, route)
|
||||
info, err := GetInfo(path, sha)
|
||||
ret.Info = info
|
||||
if err != nil {
|
||||
ret.err = err
|
||||
|
@ -1,6 +1,7 @@
|
||||
package src
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -180,7 +181,7 @@ type MICache struct {
|
||||
|
||||
var infos = NewCMap[string, *MICache]()
|
||||
|
||||
func GetInfo(path string, sha string, route string) (*MediaInfo, error) {
|
||||
func GetInfo(path string, sha string) (*MediaInfo, error) {
|
||||
var err error
|
||||
|
||||
ret, _ := infos.GetOrCreate(sha, func() *MICache {
|
||||
@ -195,7 +196,7 @@ func GetInfo(path string, sha string, route string) (*MediaInfo, error) {
|
||||
}
|
||||
|
||||
var val *MediaInfo
|
||||
val, err = getInfo(path, route)
|
||||
val, err = getInfo(path)
|
||||
*mi.info = *val
|
||||
mi.info.Sha = sha
|
||||
mi.ready.Done()
|
||||
@ -231,7 +232,7 @@ func saveInfo[T any](save_path string, mi *T) error {
|
||||
return os.WriteFile(save_path, content, 0o644)
|
||||
}
|
||||
|
||||
func getInfo(path string, route string) (*MediaInfo, error) {
|
||||
func getInfo(path string) (*MediaInfo, error) {
|
||||
defer printExecTime("mediainfo for %s", path)()
|
||||
|
||||
mi, err := mediainfo.Open(path)
|
||||
@ -294,7 +295,7 @@ func getInfo(path string, route string) (*MediaInfo, error) {
|
||||
extension := OrNull(SubtitleExtensions[format])
|
||||
var link *string
|
||||
if extension != nil {
|
||||
x := fmt.Sprintf("%s/subtitle/%d.%s", route, i, *extension)
|
||||
x := fmt.Sprintf("%s/%s/subtitle/%d.%s", Settings.RoutePrefix, base64.StdEncoding.EncodeToString([]byte(path)), i, *extension)
|
||||
link = &x
|
||||
}
|
||||
return Subtitle{
|
||||
@ -319,7 +320,7 @@ func getInfo(path string, route string) (*MediaInfo, error) {
|
||||
Fonts: Map(
|
||||
attachments,
|
||||
func(font string, _ int) string {
|
||||
return fmt.Sprintf("%s/attachment/%s", route, font)
|
||||
return fmt.Sprintf("%s/%s/attachment/%s", Settings.RoutePrefix, base64.StdEncoding.EncodeToString([]byte(path)), font)
|
||||
}),
|
||||
}
|
||||
if len(ret.Videos) > 0 {
|
||||
|
@ -11,9 +11,10 @@ func GetEnvOr(env string, def string) string {
|
||||
}
|
||||
|
||||
type SettingsT struct {
|
||||
Outpath string
|
||||
Metadata string
|
||||
HwAccel HwAccelT
|
||||
Outpath string
|
||||
Metadata string
|
||||
RoutePrefix string
|
||||
HwAccel HwAccelT
|
||||
}
|
||||
|
||||
type HwAccelT struct {
|
||||
@ -24,7 +25,8 @@ type HwAccelT struct {
|
||||
}
|
||||
|
||||
var Settings = SettingsT{
|
||||
Outpath: GetEnvOr("GOCODER_CACHE_ROOT", "/cache"),
|
||||
Metadata: GetEnvOr("GOCODER_METADATA_ROOT", "/metadata"),
|
||||
HwAccel: DetectHardwareAccel(),
|
||||
Outpath: GetEnvOr("GOCODER_CACHE_ROOT", "/cache"),
|
||||
Metadata: GetEnvOr("GOCODER_METADATA_ROOT", "/metadata"),
|
||||
RoutePrefix: GetEnvOr("GOCODER_PREFIX", ""),
|
||||
HwAccel: DetectHardwareAccel(),
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package src
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
@ -27,14 +28,14 @@ type Thumbnail struct {
|
||||
|
||||
var thumbnails = NewCMap[string, *Thumbnail]()
|
||||
|
||||
func ExtractThumbnail(path string, route string, sha string) (string, error) {
|
||||
func ExtractThumbnail(path string, sha string) (string, error) {
|
||||
ret, _ := thumbnails.GetOrCreate(sha, func() *Thumbnail {
|
||||
ret := &Thumbnail{
|
||||
path: fmt.Sprintf("%s/%s", Settings.Metadata, sha),
|
||||
}
|
||||
ret.ready.Add(1)
|
||||
go func() {
|
||||
extractThumbnail(path, ret.path, fmt.Sprintf("%s/thumbnails.png", route))
|
||||
extractThumbnail(path, ret.path)
|
||||
ret.ready.Done()
|
||||
}()
|
||||
return ret
|
||||
@ -43,7 +44,7 @@ func ExtractThumbnail(path string, route string, sha string) (string, error) {
|
||||
return ret.path, nil
|
||||
}
|
||||
|
||||
func extractThumbnail(path string, out string, name string) error {
|
||||
func extractThumbnail(path string, out string) error {
|
||||
defer printExecTime("extracting thumbnails for %s", path)()
|
||||
os.MkdirAll(out, 0o755)
|
||||
sprite_path := fmt.Sprintf("%s/sprite.png", out)
|
||||
@ -97,10 +98,11 @@ func extractThumbnail(path string, out string, name string) error {
|
||||
timestamps := ts
|
||||
ts += interval
|
||||
vtt += fmt.Sprintf(
|
||||
"%s --> %s\n%s#xywh=%d,%d,%d,%d\n\n",
|
||||
"%s --> %s\n%s/%s/thumbnails.png#xywh=%d,%d,%d,%d\n\n",
|
||||
tsToVttTime(timestamps),
|
||||
tsToVttTime(ts),
|
||||
name,
|
||||
Settings.RoutePrefix,
|
||||
base64.StdEncoding.EncodeToString([]byte(path)),
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
|
Loading…
x
Reference in New Issue
Block a user