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_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_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_seek": "00:00:01.00",
|
||||||
|
"thumb_ffmpeg_extra_args": "-hwaccel auto",
|
||||||
"thumb_libreoffice_path": "soffice",
|
"thumb_libreoffice_path": "soffice",
|
||||||
"thumb_libreoffice_max_size": "78643200", // 75 MB
|
"thumb_libreoffice_max_size": "78643200", // 75 MB
|
||||||
"thumb_libreoffice_enabled": "0",
|
"thumb_libreoffice_enabled": "0",
|
||||||
|
|
|
@ -202,6 +202,8 @@ type (
|
||||||
CustomNavItems(ctx context.Context) []CustomNavItem
|
CustomNavItems(ctx context.Context) []CustomNavItem
|
||||||
// CustomHTML returns the custom HTML settings.
|
// CustomHTML returns the custom HTML settings.
|
||||||
CustomHTML(ctx context.Context) *CustomHTML
|
CustomHTML(ctx context.Context) *CustomHTML
|
||||||
|
// FFMpegExtraArgs returns the extra arguments of ffmpeg thumb generator.
|
||||||
|
FFMpegExtraArgs(ctx context.Context) string
|
||||||
}
|
}
|
||||||
UseFirstSiteUrlCtxKey = struct{}
|
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")
|
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 {
|
func (s *settingProvider) FFMpegThumbMaxSize(ctx context.Context) int64 {
|
||||||
return s.getInt64(ctx, "thumb_ffmpeg_max_size", 10737418240)
|
return s.getInt64(ctx, "thumb_ffmpeg_max_size", 10737418240)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cloudreve/Cloudreve/v4/pkg/filemanager/driver"
|
"github.com/cloudreve/Cloudreve/v4/pkg/filemanager/driver"
|
||||||
|
@ -64,9 +65,22 @@ func (f *FfmpegGenerator) Generate(ctx context.Context, es entitysource.EntitySo
|
||||||
// Invoke ffmpeg
|
// Invoke ffmpeg
|
||||||
w, h := f.settings.ThumbSize(ctx)
|
w, h := f.settings.ThumbSize(ctx)
|
||||||
scaleOpt := fmt.Sprintf("scale=%d:%d:force_original_aspect_ratio=decrease", w, h)
|
scaleOpt := fmt.Sprintf("scale=%d:%d:force_original_aspect_ratio=decrease", w, h)
|
||||||
cmd := exec.CommandContext(ctx,
|
args := []string{
|
||||||
f.settings.FFMpegPath(ctx), "-ss", f.settings.FFMpegThumbSeek(ctx), "-i", input,
|
"-ss", f.settings.FFMpegThumbSeek(ctx),
|
||||||
"-vf", scaleOpt, "-vframes", "1", tempOutputPath)
|
}
|
||||||
|
|
||||||
|
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
|
// Redirect IO
|
||||||
var stdErr bytes.Buffer
|
var stdErr bytes.Buffer
|
||||||
|
|
Loading…
Reference in New Issue