Hi all,
I'm using Xuggler to encode videos captured from a USB camera (no audio). I create the relevant IMediaWriter as follows:
String fileName = someFileName();
IMediaWriter writer = ToolFactory.makeWriter(fileName);
VideoFormat vf = someVideoFormat();
writer.addVideoStream(0, 0, ICodec.ID.CODEC_ID_H264, vf.getWidth(), vf.getHeight());
When the capture session is finished, I do this:
writer.flush();
writer.close();
Sometimes the writer is created, but we end up not capturing any frames before the session ends, so the video file will remain empty.
However, I noticed in this scenario - when no frames are encoded - ie. the IMediaWriter is created but completely unused - writer.flush() and writer.close() both would freeze and not return, causing my app to "hang".
So 3 questions:
1) What's causing the freeze?
2) Is there a proper way to close an unused IMediaWriter, when no frames were recorded?
3) I'm currently using the following workaround, so that I can close and then delete the empty file. Would this cause any problems? (seems OK so far)
writer.getContainer.close();
thanks a lot, cheers,
King