in openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/InterviewConverter.java [71:154]
public void startConversion(Recording r) {
if (r == null) {
log.warn("Conversion is NOT started. Recording passed is NULL");
return;
}
ProcessResultList logs = new ProcessResultList();
List<File> waveFiles = new ArrayList<>();
try {
log.debug("recording {}", r.getId());
if (interviewCam == null) {
init();
}
if (Strings.isEmpty(r.getHash())) {
r.setHash(randomUUID().toString());
}
r.setStatus(Recording.Status.CONVERTING);
r = recordingDao.update(r);
File streamFolder = getStreamFolder(r);
List<RecordingChunk> chunks = chunkDao.getByRecording(r.getId());
File wav = new File(streamFolder, String.format("INTERVIEW_%s_FINAL_WAVE.wav", r.getId()));
createWav(r, logs, streamFolder, waveFiles, wav, chunks);
// Merge Audio with Video / Calculate resulting video
// group by sid first to get all pods
Map<String, List<RecordingChunk>> cunksBySid = chunks.stream().collect(
Collectors.groupingBy(RecordingChunk::getSid
, LinkedHashMap::new
, Collectors.collectingAndThen(Collectors.toList(), l -> l.stream().sorted(Comparator.comparing(RecordingChunk::getStart)).toList())));
List<String> pods = new ArrayList<>();
for (Entry<String, List<RecordingChunk>> e : cunksBySid.entrySet()) {
int podIdx = pods.size();
Date pStart = r.getRecordStart();
List<PodPart> parts = new ArrayList<>();
pStart = processParts(r.getRoomId(), e.getValue(), logs, podIdx, parts, pStart);
if (!parts.isEmpty()) {
String podX = new File(streamFolder, String.format("rec_%s_pod_%s.%s", r.getId(), podIdx, EXTENSION_MP4)).getCanonicalPath();
long diff = diff(r.getRecordEnd(), pStart);
PodPart.add(parts, diff);
createPod(podX, interviewCam, podIdx, parts, logs);
pods.add(podX);
}
}
int numPods = pods.size();
if (numPods == 0) {
ProcessResult res = new ProcessResult();
res.setProcess("CheckStreamFilesExists");
res.setError("No valid pods found");
res.setExitCode(-1);
logs.add(res);
return;
}
double ratio = Math.sqrt(numPods / Math.sqrt(2));
int w = ratio < 1 ? numPods : (int)Math.round(ratio);
w = Math.max(w, (int)Math.round(1. * numPods / w));
List<PodPart> missingParts = new ArrayList<>();
PodPart.add(missingParts, diff(r.getRecordEnd(), r.getRecordStart()));
String missingPod = new File(streamFolder, String.format("rec_%s_pod_%s.%s", r.getId(), numPods, EXTENSION_MP4)).getCanonicalPath();
createPod(missingPod, interviewBlank, numPods, missingParts, logs);
for (int i = numPods % w; i < w; ++i) {
pods.add(missingPod);
}
r.setWidth(w * WIDTH);
r.setHeight((numPods / w) * HEIGHT);
String mp4path = convertToMp4(r, getFinalArgs(pods, wav, w), numPods != 1, logs);
finalizeRec(r, mp4path, logs);
} catch (Exception err) {
log.error("[startConversion]", err);
r.setStatus(Recording.Status.ERROR);
} finally {
if (Recording.Status.CONVERTING == r.getStatus()) {
r.setStatus(Recording.Status.ERROR);
}
postProcess(r, logs);
postProcess(waveFiles);
recordingDao.update(r);
}
}