Various fixes from Discord discussions.
This commit is contained in:
Stash Dev
2019-03-27 08:34:04 -07:00
parent e05d187a77
commit 2e57c2a17a
5 changed files with 41 additions and 9 deletions

View File

@@ -28,6 +28,7 @@ func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePre
"-vf", fmt.Sprintf("scale=%v:-2", options.Width),
"-c:a", "aac",
"-b:a", "128k",
"-strict", "-2",
options.OutputPath,
}
_, _ = e.run(probeResult, args)

View File

@@ -14,6 +14,7 @@ func (e *Encoder) Transcode(probeResult VideoFile, options TranscodeOptions) {
"-crf", "23",
"-vf", "scale=iw:-2",
"-c:a", "aac",
"-strict", "-2",
options.OutputPath,
}
_, _ = e.run(probeResult, args)

View File

@@ -1,11 +1,14 @@
package manager
import (
"bytes"
"fmt"
"github.com/stashapp/stash/pkg/ffmpeg"
"github.com/stashapp/stash/pkg/logger"
"github.com/stashapp/stash/pkg/utils"
"os/exec"
"regexp"
"runtime"
"strconv"
)
@@ -45,16 +48,42 @@ func (g *GeneratorInfo) configure() error {
numberOfFrames, _ := strconv.Atoi(videoStream.NbFrames)
if numberOfFrames == 0 {
command := `ffmpeg -nostats -i ` + g.VideoFile.Path + ` -vcodec copy -f rawvideo -y /dev/null 2>&1 | \
grep frame | \
awk '{split($0,a,"fps")}END{print a[1]}' | \
sed 's/.*= *//'`
commandResult, _ := exec.Command(command).Output()
numberOfFrames, _ := strconv.Atoi(string(commandResult))
if numberOfFrames == 0 { // TODO: test
numberOfFrames = int(framerate * g.VideoFile.Duration)
args := []string{
"-nostats",
"-i", g.VideoFile.Path,
"-vcodec", "copy",
"-f", "rawvideo",
"-y",
}
if runtime.GOOS == "windows" {
args = append(args, "nul") // https://stackoverflow.com/questions/313111/is-there-a-dev-null-on-windows
} else {
args = append(args, "/dev/null")
}
command := exec.Command(instance.FFMPEGPath, args...)
var stdErrBuffer bytes.Buffer
command.Stderr = &stdErrBuffer // Frames go to stderr rather than stdout
if err := command.Run(); err == nil {
re := regexp.MustCompile(`frame[=] ([0-9]+)`)
frames := re.FindStringSubmatch(stdErrBuffer.String())
if frames != nil && len(frames) > 1 {
numberOfFrames, _ = strconv.Atoi(frames[1])
}
}
}
if numberOfFrames == 0 { // TODO: test
numberOfFrames = int(framerate * g.VideoFile.Duration)
}
if numberOfFrames == 0 {
logger.Errorf(
"number of frames is 0. nb_frames <%s> framerate <%s> duration <%s>",
videoStream.NbFrames,
framerate,
g.VideoFile.Duration,
)
}
g.NumberOfFrames = numberOfFrames
g.NthFrame = g.NumberOfFrames / g.ChunkCount

View File

@@ -81,6 +81,7 @@ func (g *SpriteGenerator) generateSpriteImage(encoder *ffmpeg.Encoder) error {
// Combine all of the thumbnails into a sprite image
globPath := filepath.Join(instance.Paths.Generated.Tmp, "thumbnail*.jpg")
imagePaths, _ := doublestar.Glob(globPath)
utils.NaturalSort(imagePaths)
var images []image.Image
for _, imagePath := range imagePaths {
img, err := imaging.Open(imagePath)

View File

@@ -21,7 +21,7 @@ func (s *singleton) Scan() {
var results []string
for _, path := range config.GetStashPaths() {
globPath := filepath.Join(path, "**/*.{zip,m4v,mp4,mov,wmv,avi}")
globPath := filepath.Join(path, "**/*.{zip,m4v,mp4,mov,wmv,avi,mpg,mpeg,rmvb,rm,flv,asf,mkv,webm}") // TODO: Make this configurable
globResults, _ := doublestar.Glob(globPath)
results = append(results, globResults...)
}