【问题标题】:Java - xuggle/ffmpeg - mov atom not foundJava - xuggle/ffmpeg - 未找到 mov 原子
【发布时间】:2011-09-04 20:41:12
【问题描述】:

我正在尝试使用 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");

有什么建议吗?

【问题讨论】:

    标签: java ffmpeg xuggle


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      container.setInputBufferLength(b.available());
      

      【讨论】:

        【解决方案3】:

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

        就我而言,我遇到了通过 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);
        

        希望这对某人有所帮助。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-09-24
          • 2017-12-26
          • 2021-05-09
          • 2021-03-12
          • 2011-09-09
          相关资源
          最近更新 更多