Java - xuggle/ffmpeg - mov atom not found
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 g开发者_高级运维ive 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?
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
container.setInputBufferLength(b.available());
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.
精彩评论