|
@@ -113,21 +113,32 @@ public class FfmpegServiceImpl implements IFfmpegService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void mergeAudioAndVideo(String srcVideoPath, String srcAudioPath, String finalVideoPath) {
|
|
|
- List<String> command = new ArrayList<>();
|
|
|
- command.add(FFMPEG_PATH);
|
|
|
- command.add("-i");
|
|
|
- command.add(srcVideoPath);
|
|
|
- command.add("-i");
|
|
|
- command.add(srcAudioPath);
|
|
|
- command.add("-c:v");
|
|
|
- command.add("copy");
|
|
|
- command.add("-c:a");
|
|
|
- command.add("aac");
|
|
|
- command.add("-strict");
|
|
|
- command.add("experimental");
|
|
|
- command.add(finalVideoPath);
|
|
|
- runCommand(command);
|
|
|
- log.info("视频文件合成成功:{}", finalVideoPath);
|
|
|
+ StringBuffer command = new StringBuffer();
|
|
|
+ command.append(FFMPEG_PATH);
|
|
|
+ command.append(" -i ");
|
|
|
+ command.append(srcVideoPath);
|
|
|
+ command.append(" -i ");
|
|
|
+ command.append(srcAudioPath);
|
|
|
+ command.append(" -c:v");
|
|
|
+ command.append(" copy");
|
|
|
+ command.append(" -c:a");
|
|
|
+ command.append(" aac");
|
|
|
+ command.append(" -strict");
|
|
|
+ command.append(" experimental ");
|
|
|
+ command.append(finalVideoPath);
|
|
|
+ Runtime runtime = Runtime.getRuntime();
|
|
|
+ Process pro = null;
|
|
|
+ try {
|
|
|
+ pro = runtime.exec(command.toString());
|
|
|
+ int status = pro.waitFor();
|
|
|
+ if (status == 0) {
|
|
|
+ log.info("视频合成成功:{}", command.toString());
|
|
|
+ } else {
|
|
|
+ log.info("视频合成失败:{}", command.toString());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|