stripAudioFirstPass(flvRecording, returnLog, listOfFullWaveFiles, streamFolderName);
// Merge Wave to Full Length
String streamFolderGeneralName = getStreamFolderName();
FlvRecordingMetaData flvRecordingMetaDataOfScreen = this.flvRecordingMetaDataDaoImpl
.getFlvRecordingMetaDataScreenFlvByRecording(flvRecording
.getFlvRecordingId());
if (flvRecordingMetaDataOfScreen == null) {
throw new Exception("flvRecordingMetaDataOfScreen is Null FlvRecordingId "+flvRecording
.getFlvRecordingId());
}
if (flvRecordingMetaDataOfScreen.getStreamReaderThreadComplete() == null) {
throw new Exception("StreamReaderThreadComplete Bit is NULL, error in recording");
}
if (!flvRecordingMetaDataOfScreen.getStreamReaderThreadComplete()) {
log.debug("### meta ScreenStream not yet written to disk" + flvRecordingMetaDataOfScreen.getFlvRecordingMetaDataId());
boolean doStop = true;
while(doStop) {
log.debug("### Stream not yet written Thread Sleep - " + flvRecordingMetaDataOfScreen.getFlvRecordingMetaDataId());
Thread.sleep(100L);
flvRecordingMetaDataOfScreen = flvRecordingMetaDataDaoImpl.getFlvRecordingMetaDataById(flvRecordingMetaDataOfScreen.getFlvRecordingMetaDataId());
if (flvRecordingMetaDataOfScreen.getStreamReaderThreadComplete()) {
log.debug("### Screen Stream now written Thread continue - " );
doStop = false;
}
}
}
String hashFileFullName = flvRecordingMetaDataOfScreen
.getStreamName() + "_FINAL_WAVE.wav";
String outputFullWav = streamFolderName + hashFileFullName;
if (listOfFullWaveFiles.size() == 1) {
outputFullWav = listOfFullWaveFiles.get(0);
flvRecordingMetaDataOfScreen
.setFullWavAudioData(hashFileFullName);
} else if (listOfFullWaveFiles.size() > 0) {
String[] argv_full_sox = mergeAudioToWaves(listOfFullWaveFiles, outputFullWav);
log.debug("START mergeAudioToWaves ################# ");
log.debug(argv_full_sox.toString());
String iString = "";
for (int i = 0; i < argv_full_sox.length; i++) {
iString += argv_full_sox[i] + " ";
}
log.debug(iString);
log.debug("END mergeAudioToWaves ################# ");
flvRecordingMetaDataOfScreen
.setFullWavAudioData(hashFileFullName);
this.flvRecordingMetaDataDaoImpl
.updateFlvRecordingMetaData(flvRecordingMetaDataOfScreen);
returnLog.add(ProcessHelper.executeScript("mergeWave",
argv_full_sox));
} else {
// create default Audio to merge it.
// strip to content length
String outputWav = streamFolderGeneralName + "one_second.wav";
// Calculate delta at beginning
Long deltaTimeMilliSeconds = flvRecording.getRecordEnd()
.getTime() - flvRecording.getRecordStart().getTime();
Float deltaPadding = (Float.parseFloat(deltaTimeMilliSeconds
.toString()) / 1000) - 1;
String[] argv_full_sox = new String[] { this.getPathToSoX(),
outputWav, outputFullWav, "pad", "0",
deltaPadding.toString() };
log.debug("START generateSampleAudio ################# ");
String tString = "";
for (int i = 0; i < argv_full_sox.length; i++) {
tString += argv_full_sox[i] + " ";
}
log.debug(tString);
log.debug("END generateSampleAudio ################# ");
flvRecordingMetaDataOfScreen
.setFullWavAudioData(hashFileFullName);
this.flvRecordingMetaDataDaoImpl
.updateFlvRecordingMetaData(flvRecordingMetaDataOfScreen);
returnLog.add(ProcessHelper.executeScript("mergeWave",
argv_full_sox));
}
// Merge Audio with Video / Calculate resulting FLV
String inputScreenFullFlv = streamFolderName
+ flvRecordingMetaDataOfScreen.getStreamName() + ".flv";
String hashFileFullNameFlv = "flvRecording_"
+ flvRecording.getFlvRecordingId() + ".flv";
String outputFullFlv = streamFolderGeneralName
+ hashFileFullNameFlv;