feat: add poster
This commit is contained in:
BIN
backend/fixtures/poster.jpg
Normal file
BIN
backend/fixtures/poster.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -1,6 +1,7 @@
|
|||||||
package discover
|
package discover
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -66,6 +67,12 @@ func (d *DiscoverMedias) RunE(from, to string) error {
|
|||||||
if err := d.ffmpegVideoToM3U8(video, to); err != nil {
|
if err := d.ffmpegVideoToM3U8(video, to); err != nil {
|
||||||
return errors.Wrapf(err, "ffmpeg video to m3u8: %s", video)
|
return errors.Wrapf(err, "ffmpeg video to m3u8: %s", video)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.log.Infof("snapshot", video)
|
||||||
|
posterPath := filepath.Join(to, "poster.jpg")
|
||||||
|
if err := d.ffmpegVideoToPoster(video, posterPath, 5); err != nil {
|
||||||
|
return errors.Wrapf(err, "ffmpeg snapshot : %s", video)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
audios := d.globAudio(dirPath)
|
audios := d.globAudio(dirPath)
|
||||||
@@ -213,3 +220,24 @@ 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 {
|
||||||
|
// 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),
|
||||||
|
"-vframes", "1",
|
||||||
|
"-vf", "scale=640:360",
|
||||||
|
output,
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Infof("cmd: ffmpeg %s", strings.Join(args, " "))
|
||||||
|
logs, err := exec.Command("ffmpeg", args...).CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "get snapshot: %s", video)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Infof("get snapshot: %s", logs)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,15 +5,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "backend"
|
"path": "backend"
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "arco"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"vue3snippets.enable-compile-vue-file-on-did-save-code": true,
|
"vue3snippets.enable-compile-vue-file-on-did-save-code": true,
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"qvyun"
|
"qvyun"
|
||||||
]
|
],
|
||||||
|
"git.ignoreLimitWarning": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user