FFmpeg: Seek input not output video

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 10:37:52 +00:00
parent 052fe82126
commit 205c0e5b2e
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.