Java - xuggle/ffmpeg - mov 原子未找到

发布于 2024-11-11 06:56:39 字数 1064 浏览 3 评论 0原文

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

有什么建议吗?

I am trying to read a mov file from local using Xuggle.
This gives me the following error:

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

The problem is that until two minutes before it didn't give any error and the code was the same.

However, I discover this:

If I open the IContainer using a byte array it doesn't work and gives me the error:

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");

if I open the IContainer using a temporary file it works.

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");

any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七色彩虹 2024-11-18 06:56:39

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

When you assign a ByteArrayInput to a DataInputStream, it may lose some data. Check if their avaiable() value is same.

洛阳烟雨空心柳 2024-11-18 06:56:39

刚刚解决了这个问题。
在使用容器之前,先设置其缓冲区大小

container.setInputBufferLength(b.available());

Just figured out this problem.
Before you use the container, set its buffer size first

container.setInputBufferLength(b.available());
如若梦似彩虹 2024-11-18 06:56:39

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

就我而言,我遇到了通过 Adob​​e Media Encoder 传递的 H264/mov 文件的问题。事实证明,AME 将 MOOV ATOM 放在了 Xuggle 不容易找到的地方。我猜在文件的末尾。

对我来说,解决方案有两个。 A) 我需要向 Xuggle 传递一个 RandomAccessFile,以便它可以来回搜索以找到 MOOV ATOM。 (FileInputStreams 不可搜索)B)我必须配置容器格式,很多在线文档和教程都将其保留为空,依靠 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);

希望这对某人有帮助。

I realize this is an old thread, but I ran across it while researching my own problem, and none of the solutions posted above helped.

In my case I was running into problems with H264/mov files which were passed through Adobe Media Encoder. Turns out AME was putting the MOOV ATOM where Xuggle couldn't readily find it. I'm guessing at the end of the file.

The solution for me was two-fold. A) I needed to pass Xuggle a RandomAccessFile so it can search back and forth to find the MOOV ATOM. (FileInputStreams aren't searchable) B)I had to configure the Container format, a lot of the documentation and tutorials online leave this as null relying on Xuggle to do autodetection.

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

Hope this helps someone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文