Skip to content

Commit

Permalink
feat: default encode audio to FLAC
Browse files Browse the repository at this point in the history
  • Loading branch information
Tohrusky committed Dec 18, 2024
1 parent a5038bd commit f673f17
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions module/ffmpeg/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ func MergeVideo(originFile string, inputFiles []string, outputPath string) error
"-map", "0:a",
"-map", "0:s",
"-disposition:v:0", "default",
"-c", "copy",
"-c:v", "copy",
"-c:a", "flac",
"-c:s", "copy",
tempVideoMergedOutputPath,
)
out, err = cmd.CombinedOutput()
log.Logger.Infof("Merged output: %s", out)
if err != nil {
// 清理可能存在的临时文件
_ = util.ClaerTempFile(tempVideoMergedOutputPath)
log.Logger.Errorf("Merge audio with audio and subtitle failed: %v, try to merge audio only", err)
// audio track
cmd = exec.Command(
Expand All @@ -76,16 +81,17 @@ func MergeVideo(originFile string, inputFiles []string, outputPath string) error
"-map", "1:v:0",
"-map", "0:a",
"-disposition:v:0", "default",
"-c", "copy",
"-c:v", "copy",
"-c:a", "flac",
tempVideoMergedOutputPath,
)
out, err = cmd.CombinedOutput()
log.Logger.Infof("Merged output: %s", out)
if err != nil {
log.Logger.Errorf("Merge audio failed: %v", err)
return err
}
}
log.Logger.Infof("Merged output: %s", out)

// 使用 mkvtoolnix 删除多余的 tags,重新混流
log.Logger.Infof("Re-mux video with mkvmerge and remove tags with mkvpropedit")
Expand Down

0 comments on commit f673f17

Please sign in to comment.