|
|
|
@ -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
|
|
|
|
|