mirror of https://github.com/cloudreve/Cloudreve
parent
15762cb393
commit
1cdccf5fc9
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit a827cc60f232ed8fb95afa6d3d434ef1c41ed251
|
||||
Subproject commit 0b49582a07eccfd63896dd18f7d944f7e96ed47d
|
|
@ -430,6 +430,7 @@ var DefaultSettings = map[string]string{
|
|||
"thumb_ffmpeg_max_size": "10737418240", // 10 GB
|
||||
"thumb_ffmpeg_exts": "3g2,3gp,asf,asx,avi,divx,flv,m2ts,m2v,m4v,mkv,mov,mp4,mpeg,mpg,mts,mxf,ogv,rm,swf,webm,wmv",
|
||||
"thumb_ffmpeg_seek": "00:00:01.00",
|
||||
"thumb_ffmpeg_extra_args": "-hwaccel auto",
|
||||
"thumb_libreoffice_path": "soffice",
|
||||
"thumb_libreoffice_max_size": "78643200", // 75 MB
|
||||
"thumb_libreoffice_enabled": "0",
|
||||
|
|
|
@ -202,6 +202,8 @@ type (
|
|||
CustomNavItems(ctx context.Context) []CustomNavItem
|
||||
// CustomHTML returns the custom HTML settings.
|
||||
CustomHTML(ctx context.Context) *CustomHTML
|
||||
// FFMpegExtraArgs returns the extra arguments of ffmpeg thumb generator.
|
||||
FFMpegExtraArgs(ctx context.Context) string
|
||||
}
|
||||
UseFirstSiteUrlCtxKey = struct{}
|
||||
)
|
||||
|
@ -406,6 +408,10 @@ func (s *settingProvider) FFMpegThumbSeek(ctx context.Context) string {
|
|||
return s.getString(ctx, "thumb_ffmpeg_seek", "00:00:01.00")
|
||||
}
|
||||
|
||||
func (s *settingProvider) FFMpegExtraArgs(ctx context.Context) string {
|
||||
return s.getString(ctx, "thumb_ffmpeg_extra_args", "")
|
||||
}
|
||||
|
||||
func (s *settingProvider) FFMpegThumbMaxSize(ctx context.Context) int64 {
|
||||
return s.getInt64(ctx, "thumb_ffmpeg_max_size", 10737418240)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue