mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +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:
@@ -40,6 +40,12 @@ func (gp *generatedPaths) GetTmpPath(fileName string) string {
|
||||
return filepath.Join(gp.Tmp, fileName)
|
||||
}
|
||||
|
||||
// TempFile creates a temporary file using os.CreateTemp.
|
||||
// It is the equivalent of calling os.CreateTemp using Tmp and pattern.
|
||||
func (gp *generatedPaths) TempFile(pattern string) (*os.File, error) {
|
||||
return os.CreateTemp(gp.Tmp, pattern)
|
||||
}
|
||||
|
||||
func (gp *generatedPaths) EnsureTmpDir() error {
|
||||
return fsutil.EnsureDir(gp.Tmp)
|
||||
}
|
||||
|
||||
@@ -6,23 +6,24 @@ import (
|
||||
)
|
||||
|
||||
type sceneMarkerPaths struct {
|
||||
generated generatedPaths
|
||||
generatedPaths
|
||||
}
|
||||
|
||||
func newSceneMarkerPaths(p Paths) *sceneMarkerPaths {
|
||||
sp := sceneMarkerPaths{}
|
||||
sp.generated = *p.Generated
|
||||
sp := sceneMarkerPaths{
|
||||
generatedPaths: *p.Generated,
|
||||
}
|
||||
return &sp
|
||||
}
|
||||
|
||||
func (sp *sceneMarkerPaths) GetStreamPath(checksum string, seconds int) string {
|
||||
return filepath.Join(sp.generated.Markers, checksum, strconv.Itoa(seconds)+".mp4")
|
||||
func (sp *sceneMarkerPaths) GetVideoPreviewPath(checksum string, seconds int) string {
|
||||
return filepath.Join(sp.Markers, checksum, strconv.Itoa(seconds)+".mp4")
|
||||
}
|
||||
|
||||
func (sp *sceneMarkerPaths) GetStreamPreviewImagePath(checksum string, seconds int) string {
|
||||
return filepath.Join(sp.generated.Markers, checksum, strconv.Itoa(seconds)+".webp")
|
||||
func (sp *sceneMarkerPaths) GetWebpPreviewPath(checksum string, seconds int) string {
|
||||
return filepath.Join(sp.Markers, checksum, strconv.Itoa(seconds)+".webp")
|
||||
}
|
||||
|
||||
func (sp *sceneMarkerPaths) GetStreamScreenshotPath(checksum string, seconds int) string {
|
||||
return filepath.Join(sp.generated.Markers, checksum, strconv.Itoa(seconds)+".jpg")
|
||||
func (sp *sceneMarkerPaths) GetScreenshotPath(checksum string, seconds int) string {
|
||||
return filepath.Join(sp.Markers, checksum, strconv.Itoa(seconds)+".jpg")
|
||||
}
|
||||
|
||||
@@ -7,25 +7,26 @@ import (
|
||||
)
|
||||
|
||||
type scenePaths struct {
|
||||
generated generatedPaths
|
||||
generatedPaths
|
||||
}
|
||||
|
||||
func newScenePaths(p Paths) *scenePaths {
|
||||
sp := scenePaths{}
|
||||
sp.generated = *p.Generated
|
||||
sp := scenePaths{
|
||||
generatedPaths: *p.Generated,
|
||||
}
|
||||
return &sp
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetScreenshotPath(checksum string) string {
|
||||
return filepath.Join(sp.generated.Screenshots, checksum+".jpg")
|
||||
return filepath.Join(sp.Screenshots, checksum+".jpg")
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetThumbnailScreenshotPath(checksum string) string {
|
||||
return filepath.Join(sp.generated.Screenshots, checksum+".thumb.jpg")
|
||||
return filepath.Join(sp.Screenshots, checksum+".thumb.jpg")
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetTranscodePath(checksum string) string {
|
||||
return filepath.Join(sp.generated.Transcodes, checksum+".mp4")
|
||||
return filepath.Join(sp.Transcodes, checksum+".mp4")
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetStreamPath(scenePath string, checksum string) string {
|
||||
@@ -37,22 +38,22 @@ func (sp *scenePaths) GetStreamPath(scenePath string, checksum string) string {
|
||||
return scenePath
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetStreamPreviewPath(checksum string) string {
|
||||
return filepath.Join(sp.generated.Screenshots, checksum+".mp4")
|
||||
func (sp *scenePaths) GetVideoPreviewPath(checksum string) string {
|
||||
return filepath.Join(sp.Screenshots, checksum+".mp4")
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetStreamPreviewImagePath(checksum string) string {
|
||||
return filepath.Join(sp.generated.Screenshots, checksum+".webp")
|
||||
func (sp *scenePaths) GetWebpPreviewPath(checksum string) string {
|
||||
return filepath.Join(sp.Screenshots, checksum+".webp")
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetSpriteImageFilePath(checksum string) string {
|
||||
return filepath.Join(sp.generated.Vtt, checksum+"_sprite.jpg")
|
||||
return filepath.Join(sp.Vtt, checksum+"_sprite.jpg")
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetSpriteVttFilePath(checksum string) string {
|
||||
return filepath.Join(sp.generated.Vtt, checksum+"_thumbs.vtt")
|
||||
return filepath.Join(sp.Vtt, checksum+"_thumbs.vtt")
|
||||
}
|
||||
|
||||
func (sp *scenePaths) GetInteractiveHeatmapPath(checksum string) string {
|
||||
return filepath.Join(sp.generated.InteractiveHeatmap, checksum+".png")
|
||||
return filepath.Join(sp.InteractiveHeatmap, checksum+".png")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user