Closed wenweiye closed 6 months ago
ffmpeg -i /home/work/baidu/aigc/bot/data/9dd1105b1be851e808824224d443dff0/output.mp4 -i /home/work/baidu/aigc/bot/data/9dd1105b1be851e808824224d443dff0/audio.ts -c:v copy -map 1:a:0 /home/work/baidu/aigc/bot/data/9dd1105b1be851e808824224d443dff0/replace.mp4 -y
if err := ffmpeg.Output( []*ffmpeg.Stream{ffmpeg.Input(videoFile).Video(), ffmpeg.Input(audioFile).Audio()}, output).SetFfmpegPath(f.path). OverWriteOutput(). ErrorToStdOut(). Run(); err != nil { logger.ErrorF(ctx, "ReplaceAudio videoFile[%s] audioFile[%s] output[%s] do error[%+v]", videoFile, audioFile, output, err) return errcode.InternalErr.Wrap(fmt.Errorf("ReplaceAudio do error [%w]", err)) } return nil
if err := ffmpeg.Input(audioFile, ffmpeg.KwArgs{ "i": videoFile, }).Output(output, ffmpeg.KwArgs{ "c:v": "copy", "map": "0:v:0", }, ffmpeg.KwArgs{ "map": "1:a:0", }).SetFfmpegPath(f.path). OverWriteOutput(). ErrorToStdOut(). Run(); err != nil { logger.ErrorF(ctx, "ReplaceAudio videoFile[%s] audioFile[%s] output[%s] do error[%+v]", videoFile, audioFile, output, err) return errcode.InternalErr.Wrap(fmt.Errorf("ReplaceAudio do error [%+v]", err)) }