|
@@ -70,7 +70,6 @@ public class VideoUtil {
|
|
|
return fileName;
|
|
|
}
|
|
|
|
|
|
- private volatile static String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
|
|
|
|
|
|
public static String mergeVideo(LinkedHashSet<String> fromVideoFileList, String newVideoFile) {
|
|
|
File tagFile = new File(newVideoFile);
|
|
@@ -78,19 +77,18 @@ public class VideoUtil {
|
|
|
tagFile.mkdirs();
|
|
|
}
|
|
|
String fileName = UUID.randomUUID().toString().replace("-","")+".mp4";
|
|
|
- newVideoFile +="/"+fileName;
|
|
|
try {
|
|
|
List<String> voidTS = new ArrayList<>();
|
|
|
|
|
|
for (String fromVideoFile : fromVideoFileList) {
|
|
|
String format = "%s -y -i %s -vcodec copy -bsf:v h264_mp4toannexb -f mpegts %s";
|
|
|
String name = fromVideoFile.substring(0, fromVideoFile.lastIndexOf("."));
|
|
|
- String command = String.format(format, ffmpeg, fromVideoFile, name + ".ts");
|
|
|
+ String command = String.format(format, "ffmpeg", fromVideoFile, newVideoFile +"/"+name + ".ts");
|
|
|
execCommand(command);
|
|
|
voidTS.add(name + ".ts");
|
|
|
}
|
|
|
StringBuilder tsPath = new StringBuilder();
|
|
|
- tsPath.append(ffmpeg);
|
|
|
+ tsPath.append("ffmpeg");
|
|
|
tsPath.append(" -i ");
|
|
|
tsPath.append("concat:");
|
|
|
for (int t = 0; t < voidTS.size(); t++) {
|
|
@@ -106,7 +104,7 @@ public class VideoUtil {
|
|
|
tsPath.append(" aac_adtstoasc ");
|
|
|
tsPath.append(" -movflags ");
|
|
|
tsPath.append(" +faststart ");
|
|
|
- tsPath.append(newVideoFile);
|
|
|
+ tsPath.append(newVideoFile +"/"+fileName);
|
|
|
execCommand(tsPath.toString());
|
|
|
//删除生成的ts文件
|
|
|
for (String filePath : voidTS) {
|