mirror of
https://github.com/cloudreve/cloudreve.git
synced 2025-12-15 10:04:01 +08:00
feat(thumb): adding option to define custom input argument for FFmpeg (#2657)
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cloudreve/Cloudreve/v4/pkg/filemanager/driver"
|
||||
@@ -64,9 +65,22 @@ func (f *FfmpegGenerator) Generate(ctx context.Context, es entitysource.EntitySo
|
||||
// Invoke ffmpeg
|
||||
w, h := f.settings.ThumbSize(ctx)
|
||||
scaleOpt := fmt.Sprintf("scale=%d:%d:force_original_aspect_ratio=decrease", w, h)
|
||||
cmd := exec.CommandContext(ctx,
|
||||
f.settings.FFMpegPath(ctx), "-ss", f.settings.FFMpegThumbSeek(ctx), "-i", input,
|
||||
"-vf", scaleOpt, "-vframes", "1", tempOutputPath)
|
||||
args := []string{
|
||||
"-ss", f.settings.FFMpegThumbSeek(ctx),
|
||||
}
|
||||
|
||||
extraArgs := f.settings.FFMpegExtraArgs(ctx)
|
||||
if extraArgs != "" {
|
||||
args = append(args, strings.Split(extraArgs, " ")...)
|
||||
}
|
||||
|
||||
args = append(args, []string{
|
||||
"-i", input,
|
||||
"-vf", scaleOpt,
|
||||
"-vframes", "1",
|
||||
tempOutputPath,
|
||||
}...)
|
||||
cmd := exec.CommandContext(ctx, f.settings.FFMpegPath(ctx), args...)
|
||||
|
||||
// Redirect IO
|
||||
var stdErr bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user