使用Xuggler流式传输video

我能够使用下面的代码成功地与Xuggler一起播放video。 我需要能够从inputStream而不是文件流。 我尝试使用注释掉的代码来创建一个Icontainer。 当我注释掉代码时,我确实修改了getTestFile方法以使用String而不是输入流。 它最初正确地获得了输入流。

当我在Icontainer上打开时,它就是无限期的块。 我不知道我是否正确接近这一点。 我怎么做基本相同的事情,但没有使用文件和使用输入流?

谢谢 :-)

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(); } } 

我想你需要做这样的事情:

  IContainer iContainer = IContainer.make(); if (iContainer.open(inputStream, IContainer.Type.READ, format) >= 0) { IMediaReader mediaReader = ToolFactory.makeReader(iContainer); ... } 

……基于javadocs的说法。 看起来需要使用IContainerFormat类的静态方法获取格式。 如果您提供null格式, open方法将尝试猜测容器类型……显然。