Hi,
I am using the Livu iPhone app to stream to a Wowza server (2.2.4), and recording the stream. I am using the code listed below to rename and move the recorded file after the live stream has finished.
Occasionally I get one of these errors:
-
The file is not renamed and moved, as if my code was not executed at all. The resulted mp4 file is also unplayable (like in problem 2).
-
The recorded mp4 file is renamed and moved but is unplayable. As far as I can say, it is missing its mp4 header.
Any idea what can cause that?
Thanks,
Eyal.
public void onWriteComplete(IMediaStream stream, File file)
{
getLogger().info("ModuleWriteListener.onWriteComplete["+stream.getContextStr()+"]: "+file);
//Long streamEndTIme = stream.getVideoTC();
Long streamTime = stream.getElapsedTime().getTime();
//Date streamDate=new Date();
//streamDate.setTime(0);
Date date = new Date();
Long streamEndTime = date.getTime();
date.setTime(streamEndTime - streamTime);
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String dateStr = dateFormat.format(date);
String ravID = file.getName().substring(0, file.getName().lastIndexOf('.'));
if (ravID.length() > 4) ravID = ravID.substring(ravID.length() - 4);
getLogger().info("ModuleWriteListener: Date = " + dateStr);
String newFileName = file.getParentFile().getAbsolutePath() + "\\" +
ravID + "\\" + ravID + "-" +
dateStr.substring(0,4) + dateStr.substring(5,7) + dateStr.substring(8,10) + "-" +
dateStr.substring(11,13) + dateStr.substring(14,16) + dateStr.substring(17,19) + "." + stream.getExt();
copyfile (file.getAbsolutePath(), newFileName);
registerFileByUrl(ravID);
}