Writing a Java application using the Play framework and need some HTTP-Live streaming. I intent to segment the mp4 files on the fly, on-demand. I tried a c-segmenter for that (from Carson McDonald) and it is very quick. However, I like to integrate the code into my Java application for easier control so tried Xuggler.
However in this setup Xuggler seems to decode and recode the object, as running it takes some significant time (24 seconds runs in about 12 seconds on MacbookPro). Is there a way to run a similar code without it doing any heavy lifting, just to cut the file in segments?
While this is quite simple with a code like the test code below:
public static void segmentMediaFile (String sourceUrl) {
Logger.debug("Starting segmenting process...");
IMediaReader mediaReader = ToolFactory.makeReader(sourceUrl);
MediaSegmenterListener listener = new MediaSegmenterListener();
IMediaReader reader = ToolFactory.makeReader(sourceUrl);
reader.addListener(listener);
int count = 0;
IMediaWriter currentWriter = makeMediaWriterFromCounter(++count, reader);
reader.addListener(currentWriter);
while (reader.readPacket() == null)
do {
if (listener.newFile()) {
reader.removeListener(currentWriter);
currentWriter.flush();
currentWriter.close();
currentWriter = makeMediaWriterFromCounter(++count, reader);
reader.addListener(currentWriter);
}
} while(false);
}
private static IMediaWriter makeMediaWriterFromCounter (final int counter, IMediaReader reader) {
String destinationUrl = "./public/testdata/test-movie/";
return ToolFactory.makeWriter(destinationUrl + counter + "_some_name.mov", reader);
}
(The listener currently just makes the decision to create a new file according to the timestamp)
Or is this the wrong way of going about it?
I wrote the code based on IPacket , algo was something like openOutput container set the streams for video and audio and then reads the packets from input container and write into outputContainer. Code is working fine without any exception etc. but only thing is i am unable to see pictures instead audio is working fine. let me know your id i will send you the code, may be you will figure out what is wrong in that.
Thanks