FFmpeg: Seek input not output video (#3893)

This improves performance when converting video to images as we no longer
have to decode and then discard the first x seconds of video.
This commit is contained in:
Alex Spurling 2023-11-19 14:55:33 +00:00 committed by GitHub
parent 052fe82126
commit d32bc4cc6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -29,7 +29,7 @@ func (c *Convert) JpegConvertCommands(f *MediaFile, jpegName string, xmpName str
// Extract a still image to be used as preview.
if f.IsAnimated() && !f.IsWebP() && c.conf.FFmpegEnabled() {
// Use "ffmpeg" to extract a JPEG still image from the video.
result = append(result, exec.Command(c.conf.FFmpegBin(), "-y", "-i", f.FileName(), "-ss", ffmpeg.PreviewTimeOffset(f.Duration()), "-vframes", "1", jpegName))
result = append(result, exec.Command(c.conf.FFmpegBin(), "-y", "-ss", ffmpeg.PreviewTimeOffset(f.Duration()), "-i", f.FileName(), "-vframes", "1", jpegName))
}
// Use heif-convert for HEIC/HEIF and AVIF image files.

View file

@ -28,7 +28,7 @@ func (c *Convert) PngConvertCommands(f *MediaFile, pngName string) (result []*ex
// Extract a video still image that can be used as preview.
if f.IsAnimated() && !f.IsWebP() && c.conf.FFmpegEnabled() {
// Use "ffmpeg" to extract a PNG still image from the video.
result = append(result, exec.Command(c.conf.FFmpegBin(), "-y", "-i", f.FileName(), "-ss", ffmpeg.PreviewTimeOffset(f.Duration()), "-vframes", "1", pngName))
result = append(result, exec.Command(c.conf.FFmpegBin(), "-y", "-ss", ffmpeg.PreviewTimeOffset(f.Duration()), "-i", f.FileName(), "-vframes", "1", pngName))
}
// Use heif-convert for HEIC/HEIF and AVIF image files.