Java - xuggle/ffmpeg - mov 原子未找到
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您将 ByteArrayInput 分配给 DataInputStream 时,它可能会丢失一些数据。检查它们的avaiable()值是否相同。
When you assign a ByteArrayInput to a DataInputStream, it may lose some data. Check if their avaiable() value is same.
刚刚解决了这个问题。
在使用容器之前,先设置其缓冲区大小
Just figured out this problem.
Before you use the container, set its buffer size first
我意识到这是一个旧线程,但我在研究自己的问题时遇到了它,上面发布的解决方案都没有帮助。
就我而言,我遇到了通过 Adobe Media Encoder 传递的 H264/mov 文件的问题。事实证明,AME 将 MOOV ATOM 放在了 Xuggle 不容易找到的地方。我猜在文件的末尾。
对我来说,解决方案有两个。 A) 我需要向 Xuggle 传递一个 RandomAccessFile,以便它可以来回搜索以找到 MOOV ATOM。 (FileInputStreams 不可搜索)B)我必须配置容器格式,很多在线文档和教程都将其保留为空,依靠 Xuggle 进行自动检测。
希望这对某人有帮助。
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.
Hope this helps someone.