stash/pkg/ffmpeg/encoder_screenshot.go

35 lines
690 B
Go
Raw Normal View History

2019-02-10 05:30:54 +00:00
package ffmpeg
import "fmt"
type ScreenshotOptions struct {
OutputPath string
Quality int
Time float64
Width int
Verbosity string
2019-02-10 05:30:54 +00:00
}
func (e *Encoder) Screenshot(probeResult VideoFile, options ScreenshotOptions) error {
2019-02-10 05:30:54 +00:00
if options.Verbosity == "" {
2019-11-04 21:34:57 +00:00
options.Verbosity = "error"
2019-02-10 05:30:54 +00:00
}
if options.Quality == 0 {
options.Quality = 1
}
args := []string{
"-v", options.Verbosity,
"-ss", fmt.Sprintf("%v", options.Time),
"-y",
"-i", probeResult.Path,
2019-02-10 05:30:54 +00:00
"-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
}