修改日志bug,和硬编码问题
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -248,9 +249,8 @@ func (s *concatService) concatByFilter(ctx context.Context, ffmpegPath string, i
|
||||
"-filter_complex", filterStr,
|
||||
"-map", "[outv]",
|
||||
"-map", "[outa]",
|
||||
"-c:v", "h264_videotoolbox",
|
||||
"-c:v", videoEncoder(),
|
||||
"-b:v", "5M",
|
||||
"-allow_sw", "true",
|
||||
"-c:a", "aac",
|
||||
"-y",
|
||||
output,
|
||||
@@ -342,6 +342,15 @@ func (s *concatService) hasVideoAudio(ctx context.Context, ffmpegPath, videoPath
|
||||
return true
|
||||
}
|
||||
|
||||
// videoEncoder 根据平台选择视频编码器
|
||||
func videoEncoder() string {
|
||||
if runtime.GOOS == "darwin" {
|
||||
return "h264_videotoolbox"
|
||||
}
|
||||
// Linux/Docker 使用 libx264(软件编码)
|
||||
return "libx264"
|
||||
}
|
||||
|
||||
func (s *concatService) getFFmpegPath() (string, error) {
|
||||
ctx := context.Background()
|
||||
ffmpegPath := g.Cfg().MustGet(ctx, "ffmpeg.path", "").String()
|
||||
@@ -565,7 +574,10 @@ func (s *concatService) processAsyncTaskWithFiles(user *beans.User, taskID strin
|
||||
|
||||
concatErr := s.executeConcat(bgCtx, taskID, filePaths, method, upload)
|
||||
if concatErr != nil {
|
||||
dao.ConcatTask.UpdateError(bgCtx, taskID, concatErr.Error())
|
||||
g.Log().Errorf(bgCtx, "[异步拼接 %s] 失败: %v", taskID, concatErr)
|
||||
if err := dao.ConcatTask.UpdateError(bgCtx, taskID, concatErr.Error()); err != nil {
|
||||
g.Log().Errorf(bgCtx, "[异步拼接 %s] 更新失败状态到数据库出错: %v", taskID, err)
|
||||
}
|
||||
s.concatCallback(bgCtx, taskID, callbackURL)
|
||||
return
|
||||
}
|
||||
@@ -620,7 +632,10 @@ func (s *concatService) processAsyncTask(user *beans.User, taskID string, videoU
|
||||
CleanupConcat(savePaths)
|
||||
|
||||
if concatErr != nil {
|
||||
dao.ConcatTask.UpdateError(bgCtx, taskID, concatErr.Error())
|
||||
g.Log().Errorf(bgCtx, "[异步拼接 %s] 失败: %v", taskID, concatErr)
|
||||
if err := dao.ConcatTask.UpdateError(bgCtx, taskID, concatErr.Error()); err != nil {
|
||||
g.Log().Errorf(bgCtx, "[异步拼接 %s] 更新失败状态到数据库出错: %v", taskID, err)
|
||||
}
|
||||
s.concatCallback(bgCtx, taskID, callbackURL)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -271,9 +271,8 @@ func (s *cutService) cutByFilterComplex(ctx context.Context, ffmpegPath, inputPa
|
||||
"-filter_complex", filterStr,
|
||||
"-map", "[outv]",
|
||||
"-map", "[outa]",
|
||||
"-c:v", "h264_videotoolbox",
|
||||
"-c:v", videoEncoder(),
|
||||
"-b:v", "5M",
|
||||
"-allow_sw", "true",
|
||||
"-c:a", "aac",
|
||||
"-y",
|
||||
outputPath,
|
||||
|
||||
Reference in New Issue
Block a user