mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Restructure ffmpeg (#2392)
* Refactor transcode generation * Move phash generation into separate package * Refactor image thumbnail generation * Move JSONTime to separate package * Ffmpeg refactoring * Refactor live transcoding * Refactor scene marker preview generation * Refactor preview generation * Refactor screenshot generation * Refactor sprite generation * Change ffmpeg.IsStreamable to return error * Move frame rate calculation into ffmpeg * Refactor file locking * Refactor title set during scan * Add missing lockmanager instance * Return error instead of logging in MatchContainer
This commit is contained in:
@@ -3,8 +3,6 @@ package ffmpeg
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
)
|
||||
|
||||
// detect file format from magic file number
|
||||
@@ -42,11 +40,10 @@ func containsMatroskaSignature(buf, subType []byte) bool {
|
||||
// Returns the zero-value on errors or no-match. Implements mkv or
|
||||
// webm only, as ffprobe can't distinguish between them and not all
|
||||
// browsers support mkv
|
||||
func magicContainer(filePath string) Container {
|
||||
func magicContainer(filePath string) (Container, error) {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
logger.Errorf("[magicfile] %v", err)
|
||||
return ""
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
@@ -54,15 +51,14 @@ func magicContainer(filePath string) Container {
|
||||
buf := make([]byte, 4096)
|
||||
_, err = file.Read(buf)
|
||||
if err != nil {
|
||||
logger.Errorf("[magicfile] %v", err)
|
||||
return ""
|
||||
return "", err
|
||||
}
|
||||
|
||||
if webm(buf) {
|
||||
return Webm
|
||||
return Webm, nil
|
||||
}
|
||||
if mkv(buf) {
|
||||
return Matroska
|
||||
return Matroska, nil
|
||||
}
|
||||
return ""
|
||||
return "", nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user