use of org.apache.openmeetings.db.entity.record.RecordingMetaData in project openmeetings by apache.
the class BaseConverter method stripAudioFirstPass.
protected void stripAudioFirstPass(Recording recording, ProcessResultList logs, List<File> waveFiles, File streamFolder, List<RecordingMetaData> metaDataList) {
try {
// Init variables
log.debug("### meta Data Number - {}", metaDataList.size());
log.debug("###################################################");
for (RecordingMetaData metaData : metaDataList) {
long metaId = metaData.getId();
log.debug("### processing metadata: {}", metaId);
if (metaData.getStreamStatus() == Status.NONE) {
log.debug("Stream has not been started, error in recording {}", metaId);
continue;
}
metaData = waitForTheStream(metaId);
File inputFlvFile = new File(streamFolder, OmFileHelper.getName(metaData.getStreamName(), EXTENSION_FLV));
File outputWav = new File(streamFolder, metaData.getStreamName() + "_WAVE.wav");
log.debug("FLV File Name: {} Length: {} ", inputFlvFile.getName(), inputFlvFile.length());
if (inputFlvFile.exists()) {
String[] argv = new String[] { getPathToFFMPEG(), "-y", "-i", inputFlvFile.getCanonicalPath(), "-af", String.format("aresample=%s:min_comp=0.001:min_hard_comp=0.100000", getAudioBitrate()), outputWav.getCanonicalPath() };
// there might be no audio in the stream
logs.add(ProcessHelper.executeScript("stripAudioFromFLVs", argv, true));
}
if (outputWav.exists() && outputWav.length() != 0) {
metaData.setAudioValid(true);
// Strip Wave to Full Length
File outputGapFullWav = outputWav;
// Fix Start/End in Audio
List<RecordingMetaDelta> metaDeltas = metaDeltaDao.getByMetaId(metaId);
int counter = 0;
for (RecordingMetaDelta metaDelta : metaDeltas) {
File inputFile = outputGapFullWav;
// Strip Wave to Full Length
String hashFileGapsFullName = metaData.getStreamName() + "_GAP_FULL_WAVE_" + counter + ".wav";
outputGapFullWav = new File(streamFolder, hashFileGapsFullName);
metaDelta.setWaveOutPutName(hashFileGapsFullName);
String[] soxArgs = null;
if (metaDelta.getDeltaTime() != null) {
double gapSeconds = diffSeconds(metaDelta.getDeltaTime());
if (metaDelta.isStartPadding()) {
soxArgs = addSoxPad(logs, "fillGap", gapSeconds, 0, inputFile, outputGapFullWav);
} else if (metaDelta.isEndPadding()) {
soxArgs = addSoxPad(logs, "fillGap", 0, gapSeconds, inputFile, outputGapFullWav);
}
}
if (soxArgs != null) {
log.debug("START fillGap ################# Delta-ID :: {}", metaDelta.getId());
metaDeltaDao.update(metaDelta);
counter++;
} else {
outputGapFullWav = inputFile;
}
}
// Strip Wave to Full Length
String hashFileFullName = metaData.getStreamName() + "_FULL_WAVE.wav";
File outputFullWav = new File(streamFolder, hashFileFullName);
// Calculate delta at beginning
double startPad = diffSeconds(metaData.getRecordStart(), recording.getRecordStart());
// Calculate delta at ending
double endPad = diffSeconds(recording.getRecordEnd(), metaData.getRecordEnd());
addSoxPad(logs, "addStartEndToAudio", startPad, endPad, outputGapFullWav, outputFullWav);
// Fix for Audio Length - Invalid Audio Length in Recorded Files
// Audio must match 100% the Video
log.debug("############################################");
log.debug("Trim Audio to Full Length -- Start");
if (!outputFullWav.exists()) {
throw new ConversionException("Audio File does not exist , could not extract the Audio correctly");
}
metaData.setFullWavAudioData(hashFileFullName);
// Finally add it to the row!
waveFiles.add(outputFullWav);
}
metaDataDao.update(metaData);
}
} catch (Exception err) {
log.error("[stripAudioFirstPass]", err);
}
}
use of org.apache.openmeetings.db.entity.record.RecordingMetaData in project openmeetings by apache.
the class BaseConverter method waitForTheStream.
protected RecordingMetaData waitForTheStream(long metaId) throws InterruptedException {
RecordingMetaData metaData = metaDataDao.get(metaId);
if (metaData.getStreamStatus() != Status.STOPPED) {
log.debug("### meta Stream not yet written to disk {}", metaId);
long counter = 0;
long maxTimestamp = 0;
while (true) {
log.trace("### Stream not yet written Thread Sleep - {}", metaId);
metaData = metaDataDao.get(metaId);
if (metaData.getStreamStatus() == Status.STOPPED) {
printMetaInfo(metaData, "Stream now written");
log.debug("### Thread continue ... ");
break;
} else {
File metaFlv = getRecordingMetaData(metaData.getRecording().getRoomId(), metaData.getStreamName());
if (metaFlv.exists() && maxTimestamp < metaFlv.lastModified()) {
maxTimestamp = metaFlv.lastModified();
}
File metaSer = getMetaFlvSer(metaData);
if (metaSer.exists() && maxTimestamp < metaSer.lastModified()) {
maxTimestamp = metaSer.lastModified();
}
if (maxTimestamp + TIME_TO_WAIT_FOR_FRAME < System.currentTimeMillis()) {
if (metaSer.exists()) {
log.debug("### long time without any update, trying to repair ... ");
/*
try {
if (FLVWriter.repair(metaSer.getCanonicalPath(), null, null) && !metaSer.exists()) {
log.debug("### Repairing was successful ... ");
} else {
log.debug("### Repairing was NOT successful ... ");
}
} catch (IOException e) {
log.error("### Error while file repairing ... ", e);
}
*/
} else {
log.debug("### long time without any update, closing ... ");
}
metaData.setStreamStatus(Status.STOPPED);
metaDataDao.update(metaData);
break;
}
}
if (++counter % 1000 == 0) {
printMetaInfo(metaData, "Still waiting");
}
Thread.sleep(100L);
}
}
return metaData;
}
use of org.apache.openmeetings.db.entity.record.RecordingMetaData in project openmeetings by apache.
the class BackupImport method importRecordings.
/*
* ##################### Import Recordings
*/
private void importRecordings(File f) throws Exception {
log.info("Meeting members import complete, starting recordings server import");
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
RegistryMatcher matcher = new RegistryMatcher();
Serializer ser = new Persister(strategy, matcher);
matcher.bind(Long.class, LongTransform.class);
matcher.bind(Integer.class, IntegerTransform.class);
registry.bind(Date.class, DateConverter.class);
registry.bind(Recording.Status.class, RecordingStatusConverter.class);
List<Recording> list = readList(ser, f, "flvRecordings.xml", "flvrecordings", Recording.class);
for (Recording r : list) {
Long recId = r.getId();
r.setId(null);
if (r.getRoomId() != null) {
r.setRoomId(roomMap.get(r.getRoomId()));
}
if (r.getOwnerId() != null) {
r.setOwnerId(userMap.get(r.getOwnerId()));
}
if (r.getMetaData() != null) {
for (RecordingMetaData meta : r.getMetaData()) {
meta.setId(null);
meta.setRecording(r);
}
}
if (!Strings.isEmpty(r.getHash()) && r.getHash().startsWith(RECORDING_FILE_NAME)) {
String name = getFileName(r.getHash());
r.setHash(UUID.randomUUID().toString());
fileMap.put(String.format(FILE_NAME_FMT, name, EXTENSION_JPG), String.format(FILE_NAME_FMT, r.getHash(), EXTENSION_PNG));
fileMap.put(String.format("%s.%s.%s", name, EXTENSION_FLV, EXTENSION_MP4), String.format(FILE_NAME_FMT, r.getHash(), EXTENSION_MP4));
}
if (Strings.isEmpty(r.getHash())) {
r.setHash(UUID.randomUUID().toString());
}
r = recordingDao.update(r);
fileItemMap.put(recId, r.getId());
}
}
use of org.apache.openmeetings.db.entity.record.RecordingMetaData in project openmeetings by apache.
the class RecordingMetaDataDao method updateEndDate.
public Long updateEndDate(Long metaId, Date recordEnd) {
try {
RecordingMetaData meta = get(metaId);
if (meta != null) {
meta.setRecordEnd(recordEnd);
log.debug("updateEndDate :: Start Date : {}", meta.getRecordStart());
log.debug("updateEndDate :: End Date : {}", meta.getRecordEnd());
update(meta);
}
return metaId;
} catch (Exception ex2) {
log.error("[updateEndDate]: ", ex2);
}
return null;
}
Aggregations