photoprism/internal/ffmpeg/preview.go
Michael Mayer 97c9962053 Index: Add experimental EPS and SVG vector graphics support #1177 #2207
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-02-11 20:18:04 +01:00

27 lines
670 B
Go

package ffmpeg
import "time"
// PreviewTimeOffset returns an appropriate time offset depending on the duration for extracting a preview image.
func PreviewTimeOffset(d time.Duration) string {
// Default.
result := "00:00:00.001"
// If the video is long enough, don't use the first frames to avoid completely
// black or white thumbnails in case there is an effect or intro.
switch {
case d > time.Hour:
result = "00:02:30.000"
case d > 10*time.Minute:
result = "00:01:00.000"
case d > 3*time.Minute:
result = "00:00:30.000"
case d > time.Minute:
result = "00:00:09.000"
case d > time.Millisecond*3100:
result = "00:00:03.000"
}
return result
}