mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
* Added preview generation fallback feature. When a preview generation fails (often for wmv/avi files), the new code tries with less stricted (no xerror) and more time consuming options (slow+fast seek). Fix a minor issue when stash downloads ffmpeg/ffprobe, but doesn't re-detect their paths.
34 lines
690 B
Go
34 lines
690 B
Go
package ffmpeg
|
|
|
|
import "fmt"
|
|
|
|
type ScreenshotOptions struct {
|
|
OutputPath string
|
|
Quality int
|
|
Time float64
|
|
Width int
|
|
Verbosity string
|
|
}
|
|
|
|
func (e *Encoder) Screenshot(probeResult VideoFile, options ScreenshotOptions) error {
|
|
if options.Verbosity == "" {
|
|
options.Verbosity = "error"
|
|
}
|
|
if options.Quality == 0 {
|
|
options.Quality = 1
|
|
}
|
|
args := []string{
|
|
"-v", options.Verbosity,
|
|
"-ss", fmt.Sprintf("%v", options.Time),
|
|
"-y",
|
|
"-i", probeResult.Path,
|
|
"-vframes", "1",
|
|
"-q:v", fmt.Sprintf("%v", options.Quality),
|
|
"-vf", fmt.Sprintf("scale=%v:-1", options.Width),
|
|
"-f", "image2",
|
|
options.OutputPath,
|
|
}
|
|
_, err := e.run(probeResult, args)
|
|
|
|
return err
|
|
}
|