1

我正在尝试使用 Xuggle 从本地读取 mov 文件。这给了我以下错误:

30-mag-2011 15.56.55 com.xuggle.ferry.NativeLogger log
GRAVE: [mov,mp4,m4a,3gp,3g2,mj2 @ 0x102840600] moov atom not found

问题是直到两分钟前它没有给出任何错误并且代码是相同的。

但是,我发现了这一点:

如果我使用字节数组打开 IContainer 它将不起作用并给我错误:

ByteArrayInputStream b = new ByteArrayInputStream(file);
DataInputStream data = new DataInputStream(b);
IContainer container = IContainer.make();
if (container.open(data, null) < 0)
    throw new IllegalArgumentException("E001 - Cannot open the container");

如果我使用临时文件打开 IContainer ,它就可以工作。

File temp = File.createTempFile("temp_", ".mov");

try
{
    FileOutputStream fos = new FileOutputStream(temp);
    fos.write(file);
    fos.close();
}
catch(FileNotFoundException e)
{
    System.out.println(e);
}

IContainer container = IContainer.make();

if (container.open(temp.toString(), IContainer.Type.READ, null) < 0)
    throw new IllegalArgumentException("E001 - Cannot open the container");

有什么建议么?

4

3 回答 3

0

刚想通这个问题。
在使用容器之前,先设置它的缓冲区大小

container.setInputBufferLength(b.available());
于 2011-09-05T19:12:58.737 回答
0

当您将 ByteArrayInput 分配给 DataInputStream 时,它可能会丢失一些数据。检查它们的avaiable() 值是否相同。

于 2011-09-05T17:34:52.290 回答
0

我意识到这是一个旧线程,但是我在研究自己的问题时遇到了它,上面发布的解决方案都没有帮助。

就我而言,我遇到了通过 Adob​​e Media Encoder 传递的 H264/mov 文件的问题。结果发现 AME 将 MOOV ATOM 放在了 Xuggle 无法轻易找到的地方。我猜在文件的末尾。

对我来说,解决方案有两个。A) 我需要向 Xuggle 传递一个 RandomAccessFile,以便它可以来回搜索以找到 MOOV ATOM。(FileInputStreams 不可搜索) B)我必须配置 Container 格式,许多在线文档和教程将其设置为空,依靠 Xuggle 进行自动检测。

RandomAccessFile f = new RandomAccessFile("C:/MyMovie.mov", "r");
IContainer container = IContainer.make();
IContainerFormat format = IContainerFormat.make();
if (format.setInputFormat("mov") < 0) 
    System.out.println("Error setting format");

int result = container.open(f, IContainer.Type.READ, format);

希望这可以帮助某人。

于 2013-12-05T17:36:27.523 回答