2019-02-09 12:30:49 +00:00
|
|
|
package manager
|
|
|
|
|
2019-02-11 20:12:08 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2019-10-13 23:58:46 +00:00
|
|
|
|
|
|
|
"github.com/stashapp/stash/pkg/ffmpeg"
|
2019-02-14 23:42:52 +00:00
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
|
|
"github.com/stashapp/stash/pkg/utils"
|
2019-02-11 20:12:08 +00:00
|
|
|
)
|
2019-02-09 12:30:49 +00:00
|
|
|
|
2019-02-11 20:12:08 +00:00
|
|
|
func IsStreamable(scene *models.Scene) (bool, error) {
|
|
|
|
if scene == nil {
|
|
|
|
return false, fmt.Errorf("nil scene")
|
|
|
|
}
|
2019-02-09 12:30:49 +00:00
|
|
|
|
2019-10-13 23:58:46 +00:00
|
|
|
videoCodec := scene.VideoCodec.String
|
|
|
|
if ffmpeg.IsValidCodec(videoCodec) {
|
2019-02-09 12:30:49 +00:00
|
|
|
return true, nil
|
2019-10-13 23:58:46 +00:00
|
|
|
} else {
|
2019-02-20 00:21:38 +00:00
|
|
|
hasTranscode, _ := HasTranscode(scene)
|
|
|
|
return hasTranscode, nil
|
2019-02-11 20:12:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func HasTranscode(scene *models.Scene) (bool, error) {
|
|
|
|
if scene == nil {
|
|
|
|
return false, fmt.Errorf("nil scene")
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
2019-02-11 20:12:08 +00:00
|
|
|
transcodePath := instance.Paths.Scene.GetTranscodePath(scene.Checksum)
|
|
|
|
return utils.FileExists(transcodePath)
|
2019-02-14 22:53:32 +00:00
|
|
|
}
|