mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Fix ffmpeg error output (#176)
This commit is contained in:
@@ -59,8 +59,8 @@ func KillRunningEncoders(path string) {
|
|||||||
// wait for the process to die before returning
|
// wait for the process to die before returning
|
||||||
// don't wait more than a few seconds
|
// don't wait more than a few seconds
|
||||||
done := make(chan error)
|
done := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
_, err := process.Wait()
|
_, err := process.Wait()
|
||||||
done <- err
|
done <- err
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -91,6 +91,7 @@ func (e *Encoder) run(probeResult VideoFile, args []string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, 80)
|
buf := make([]byte, 80)
|
||||||
|
var errBuilder strings.Builder
|
||||||
for {
|
for {
|
||||||
n, err := stderr.Read(buf)
|
n, err := stderr.Read(buf)
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
@@ -100,6 +101,8 @@ func (e *Encoder) run(probeResult VideoFile, args []string) (string, error) {
|
|||||||
progress := time / probeResult.Duration
|
progress := time / probeResult.Duration
|
||||||
logger.Infof("Progress %.2f", progress)
|
logger.Infof("Progress %.2f", progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errBuilder.WriteString(data)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
@@ -113,7 +116,8 @@ func (e *Encoder) run(probeResult VideoFile, args []string) (string, error) {
|
|||||||
err = waitAndDeregister(probeResult.Path, cmd)
|
err = waitAndDeregister(probeResult.Path, cmd)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("ffmpeg error when running command <%s>: %s", strings.Join(cmd.Args, " "), stdoutString)
|
// error message should be in the stderr stream
|
||||||
|
logger.Errorf("ffmpeg error when running command <%s>: %s", strings.Join(cmd.Args, " "), errBuilder.String())
|
||||||
return stdoutString, err
|
return stdoutString, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type SceneMarkerOptions struct {
|
|||||||
|
|
||||||
func (e *Encoder) SceneMarkerVideo(probeResult VideoFile, options SceneMarkerOptions) error {
|
func (e *Encoder) SceneMarkerVideo(probeResult VideoFile, options SceneMarkerOptions) error {
|
||||||
args := []string{
|
args := []string{
|
||||||
"-v", "quiet",
|
"-v", "error",
|
||||||
"-ss", strconv.Itoa(options.Seconds),
|
"-ss", strconv.Itoa(options.Seconds),
|
||||||
"-t", "20",
|
"-t", "20",
|
||||||
"-i", probeResult.Path,
|
"-i", probeResult.Path,
|
||||||
@@ -40,7 +40,7 @@ func (e *Encoder) SceneMarkerVideo(probeResult VideoFile, options SceneMarkerOpt
|
|||||||
|
|
||||||
func (e *Encoder) SceneMarkerImage(probeResult VideoFile, options SceneMarkerOptions) error {
|
func (e *Encoder) SceneMarkerImage(probeResult VideoFile, options SceneMarkerOptions) error {
|
||||||
args := []string{
|
args := []string{
|
||||||
"-v", "quiet",
|
"-v", "error",
|
||||||
"-ss", strconv.Itoa(options.Seconds),
|
"-ss", strconv.Itoa(options.Seconds),
|
||||||
"-t", "5",
|
"-t", "5",
|
||||||
"-i", probeResult.Path,
|
"-i", probeResult.Path,
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package ffmpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/stashapp/stash/pkg/utils"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/stashapp/stash/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScenePreviewChunkOptions struct {
|
type ScenePreviewChunkOptions struct {
|
||||||
@@ -14,7 +15,7 @@ type ScenePreviewChunkOptions struct {
|
|||||||
|
|
||||||
func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePreviewChunkOptions) {
|
func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePreviewChunkOptions) {
|
||||||
args := []string{
|
args := []string{
|
||||||
"-v", "quiet",
|
"-v", "error",
|
||||||
"-ss", strconv.Itoa(options.Time),
|
"-ss", strconv.Itoa(options.Time),
|
||||||
"-t", "0.75",
|
"-t", "0.75",
|
||||||
"-i", probeResult.Path,
|
"-i", probeResult.Path,
|
||||||
@@ -38,7 +39,7 @@ func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePre
|
|||||||
|
|
||||||
func (e *Encoder) ScenePreviewVideoChunkCombine(probeResult VideoFile, concatFilePath string, outputPath string) {
|
func (e *Encoder) ScenePreviewVideoChunkCombine(probeResult VideoFile, concatFilePath string, outputPath string) {
|
||||||
args := []string{
|
args := []string{
|
||||||
"-v", "quiet",
|
"-v", "error",
|
||||||
"-f", "concat",
|
"-f", "concat",
|
||||||
"-i", utils.FixWindowsPath(concatFilePath),
|
"-i", utils.FixWindowsPath(concatFilePath),
|
||||||
"-y",
|
"-y",
|
||||||
@@ -50,7 +51,7 @@ func (e *Encoder) ScenePreviewVideoChunkCombine(probeResult VideoFile, concatFil
|
|||||||
|
|
||||||
func (e *Encoder) ScenePreviewVideoToImage(probeResult VideoFile, width int, videoPreviewPath string, outputPath string) error {
|
func (e *Encoder) ScenePreviewVideoToImage(probeResult VideoFile, width int, videoPreviewPath string, outputPath string) error {
|
||||||
args := []string{
|
args := []string{
|
||||||
"-v", "quiet",
|
"-v", "error",
|
||||||
"-i", videoPreviewPath,
|
"-i", videoPreviewPath,
|
||||||
"-y",
|
"-y",
|
||||||
"-c:v", "libwebp",
|
"-c:v", "libwebp",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type ScreenshotOptions struct {
|
|||||||
|
|
||||||
func (e *Encoder) Screenshot(probeResult VideoFile, options ScreenshotOptions) {
|
func (e *Encoder) Screenshot(probeResult VideoFile, options ScreenshotOptions) {
|
||||||
if options.Verbosity == "" {
|
if options.Verbosity == "" {
|
||||||
options.Verbosity = "quiet"
|
options.Verbosity = "error"
|
||||||
}
|
}
|
||||||
if options.Quality == 0 {
|
if options.Quality == 0 {
|
||||||
options.Quality = 1
|
options.Quality = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user