List<ConverterProcessResult> returnLog = new ArrayList<ConverterProcessResult>();
List<String> listOfFullWaveFiles = new LinkedList<String>();
File streamFolder = getStreamFolder(flvRecording);
FlvRecordingMetaData screenMetaData = metaDataDao.getScreenMetaDataByRecording(flvRecording.getFlvRecordingId());
if (screenMetaData == null) {
throw new Exception("screenMetaData is Null FlvRecordingId " + flvRecording.getFlvRecordingId());
}
if (screenMetaData.getStreamStatus() == Status.NONE) {
throw new Exception("Stream has not been started, error in recording");
}
screenMetaData = waitForTheStream(screenMetaData.getFlvRecordingMetaDataId());
stripAudioFirstPass(flvRecording, returnLog, listOfFullWaveFiles, streamFolder);
// Merge Wave to Full Length
String streamFolderGeneralName = getStreamsHibernateDir().getCanonicalPath() + File.separator; // FIXME
String hashFileFullName = screenMetaData.getStreamName() + "_FINAL_WAVE.wav";
String outputFullWav = new File(streamFolder, hashFileFullName).getCanonicalPath();
if (listOfFullWaveFiles.size() == 1) {
outputFullWav = listOfFullWaveFiles.get(0);
} else if (listOfFullWaveFiles.size() > 0) {
String[] argv_full_sox = mergeAudioToWaves(listOfFullWaveFiles, outputFullWav);
returnLog.add(ProcessHelper.executeScript("mergeAudioToWaves", 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[] { getPathToSoX(), outputWav, outputFullWav, "pad", "0", deltaPadding.toString() };
returnLog.add(ProcessHelper.executeScript("generateSampleAudio", argv_full_sox));
}
screenMetaData.setFullWavAudioData(hashFileFullName);
metaDataDao.update(screenMetaData);
// Merge Audio with Video / Calculate resulting FLV
String inputScreenFullFlv = new File(streamFolder, screenMetaData.getStreamName() + ".flv")
.getCanonicalPath();
String hashFileFullNameFlv = "flvRecording_" + flvRecording.getFlvRecordingId() + ".flv";
String outputFullFlv = streamFolderGeneralName + hashFileFullNameFlv;
// ffmpeg -vcodec flv -qscale 9.5 -r 25 -ar 22050 -ab 32k -s 320x240
// -i 65318fb5c54b1bc1b1bca077b493a914_28_12_2009_23_38_17_FINAL_WAVE.wav
// -i 65318fb5c54b1bc1b1bca077b493a914_28_12_2009_23_38_17.flv
// final1.flv
int flvWidth = flvRecording.getWidth();
int flvHeight = flvRecording.getHeight();
log.debug("flvWidth -1- " + flvWidth);
log.debug("flvHeight -1- " + flvHeight);
flvWidth = Double.valueOf((Math.floor(flvWidth / 16)) * 16).intValue();
flvHeight = Double.valueOf((Math.floor(flvHeight / 16)) * 16).intValue();
log.debug("flvWidth -2- " + flvWidth);
log.debug("flvHeight -2- " + flvHeight);
flvRecording.setFlvWidth(flvWidth);
flvRecording.setFlvHeight(flvHeight);
String[] argv_fullFLV = new String[] { getPathToFFMPEG(), //
"-itsoffset", getDifference(screenMetaData.getRecordStart(), screenMetaData.getFlvRecording().getRecordStart()),
"-i", inputScreenFullFlv, "-i", outputFullWav, "-ar", "22050", //
"-acodec", "libmp3lame", //
"-ab", "32k", //
"-s", flvWidth + "x" + flvHeight, //
"-vcodec", "flashsv", //