|
@@ -319,22 +319,28 @@ public class FfmpegServiceImpl implements IFfmpegService {
|
|
|
//3.1 抽取音频文件
|
|
|
String srcM4aFilePath = splitSrcPath + "src.m4a";
|
|
|
getM4aFromMp4(srcFilePath, srcM4aFilePath);
|
|
|
+ log.info("提取原始音频文件成功:{}", srcM4aFilePath);
|
|
|
String fillM4aFilePath = splitSrcPath + "fill.m4a";
|
|
|
getM4aFromMp4(fillFilePath, fillM4aFilePath);
|
|
|
+ log.info("提取填充音频文件成功:{}", fillM4aFilePath);
|
|
|
//3.2 截取源模板音频文件
|
|
|
String cutM4aFilePath = splitSrcPath + "cut.m4a";
|
|
|
//计算需要截取的音频时长
|
|
|
String secondStr = getSecond(exchangeStartFrameNum);
|
|
|
cutM4a(srcM4aFilePath, cutM4aFilePath, "00:00:00.000", secondStr);
|
|
|
+ log.info("音频文件截取成功:{}", cutM4aFilePath);
|
|
|
//3.3 合并两个音频文件
|
|
|
String finalM4aFilePath = splitSrcPath + "final.m4a";
|
|
|
audioMosaic(cutM4aFilePath, fillM4aFilePath, finalM4aFilePath);
|
|
|
+ log.info("音频文件合成成功:{}", finalM4aFilePath);
|
|
|
//3.4 将最终生成的图片合成为视频
|
|
|
String noVoiceVideoFilePath = splitSrcPath + "novoice.mp4";
|
|
|
mergeImageToVideo(splitFinalPath, 25, noVoiceVideoFilePath);
|
|
|
+ log.info("图片合成视频成功:{}", noVoiceVideoFilePath);
|
|
|
//3.5 合并视频和音频
|
|
|
String finalVideoFilePath = splitSrcPath + "final.mp4";
|
|
|
mergeAudioAndVideo(noVoiceVideoFilePath, finalM4aFilePath, finalVideoFilePath);
|
|
|
+ log.info("视频文件合成成功:{}", finalVideoFilePath);
|
|
|
//3.6 上传视频文件至OSS并返回url存入数据库
|
|
|
InputStream inputStream = new FileInputStream(finalVideoFilePath);
|
|
|
String finalUrl = OSSUtils.uploadFile2OSS(inputStream, "model/final/", videoInfo.getId() + "_" + current + ".mp4");
|