我正在尝试从本地读取mov文件,使用的是Xuggle。这会给我以下错误:
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");有什么建议吗?
发布于 2011-09-06 01:34:52
将ByteArrayInput分配给DataInputStream时,它可能会丢失一些数据。检查它们的avaiable()值是否相同。
发布于 2011-09-06 03:12:59
刚刚弄明白了这个问题。
在使用容器之前,请先设置其缓冲区大小
container.setInputBufferLength(b.available());发布于 2013-12-06 01:36:28
我意识到这是一个老问题,但我在研究自己的问题时遇到了它,上面发布的解决方案都没有帮助。
在我的例子中,我遇到了通过Adobe Media Encoder传递的H264/mov文件的问题。原来AME把MOOV原子放在徐格找不到的地方。我猜是在文件的最后。
对我来说,解决方案有两个方面。A)我需要传递给徐谷一个RandomAccessFile,这样它就可以来回搜索以找到MOOV原子。(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);希望这对某些人有帮助。
https://stackoverflow.com/questions/6177346
复制相似问题