I was able to successfully play video with Xuggler with the code below. I need to be able to stream from an inputStream instead of a file. I tried using the commented out code to create an Icontainer. I did modified the getTestFile method to use a String instead of an inputstream when I commented out the code. It was originally getting the inputstream correctly.
When I call open on Icontainer is just blocks indefinitely. I don't know if I'm approaching this correctly. How would I do basically the same thing but without use a file and using an input stream?
Thanks :-)
package com.plumber.testing;
import com.xuggle.mediatool.IMediaReader;
import com.xuggle.mediatool.IMediaViewer;
import com.xuggle.mediatool.ToolFactory;
import com.xuggle.xuggler.IContainer;
import java.io.FileNotFoundException;
import java.io.InputStream;
public class VideoTest {
public static void main(String[] args) throws FileNotFoundException {
// IContainer iContainer = IContainer.make();
// iContainer.open(getTestFile("IMG_0983.MOV"), null);
// I was originally passing the icontainer to make reader
IMediaReader mediaReader = ToolFactory.makeReader(getTestFile("IMG_0983.MOV"));
IMediaViewer mediaViewer = ToolFactory.makeViewer(true);
mediaReader.addListener(mediaViewer);
while (mediaReader.readPacket() == null) ;
}
private static String getTestFile(String fileName) {
return VideoTest.class.getClassLoader().getResource("com/plumber/testing/testfiles/" + fileName).getPath();
}
}
I think you need to do something like this:
... based on what the javadocs say. It looks like the format needs to be obtained using static methods of the
IContainerFormat
class. If you supply anull
format, theopen
method will attempt to guess the container type ... apparently.