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