2011-05-30 85 views
1

我想从本地读取使用Xuggle的mov文件。 这给了我下面的错误:Java - xuggle/ffmpeg - 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"); 

有什么建议吗?

回答

0

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

0

刚刚发现了这个问题。
在你使用的容器,设置它的缓冲区大小第一

container.setInputBufferLength(b.available()); 
0

我意识到这是一个古老的线程,但我碰到它跑,同时研究我自己的问题,并没有解决方案的发布上述帮助。

在我的情况下,我遇到了通过Adobe Media Encoder传递的H264/mov文件的问题。原来,AME把MOOV ATOM放在了Xuggle找不到的地方。我猜在文件的末尾。

对我来说,解决方案是双重的。 A)我需要通过Xuggle一个RandomAccessFile,以便它可以来回搜索以找到MOOV ATOM。 (FileInputStreams不可搜索)B)我必须配置容器格式,许多文档和教程在线离开此为null依靠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); 

希望这可以帮助别人。