diff --git a/backend/modules/tasks/discover/discover_medias.go b/backend/modules/tasks/discover/discover_medias.go index c29dd4d..5e1a3f0 100644 --- a/backend/modules/tasks/discover/discover_medias.go +++ b/backend/modules/tasks/discover/discover_medias.go @@ -110,6 +110,12 @@ func (d *DiscoverMedias) processVideo(video string, to string) (media_store.Vide return info, errors.Wrapf(err, "ffmpeg audio to m3u8: %s", audioFile) } + // extract poster + posterFile := filepath.Join(to, "poster.jpg") + if err := d.ffmpegVideoToPoster(video, posterFile); err != nil { + return info, errors.Wrapf(err, "ffmpeg video to poster: %s", video) + } + // get media duration duration, err := d.getMediaDuration(video) if err != nil { @@ -261,11 +267,11 @@ func (d *DiscoverMedias) runCleanup(to string) { } // getSnapshot get the snapshot of target seconds of a video -func (d *DiscoverMedias) ffmpegVideoToPoster(video string, output string, seconds int) error { +func (d *DiscoverMedias) ffmpegVideoToPoster(video string, output string) error { // ffmpeg -i input_video.mp4 -ss N -vframes 1 -vf "scale=width:height" output_image.jpg args := []string{ "-i", video, - "-ss", fmt.Sprintf("00:%02d:00", seconds), + "-ss", "00:01:00", "-vframes", "1", "-vf", "scale=640:360", output,