2011-05-30 40 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); 

希望這可以幫助別人。