5

I am trying to open a video file with xuggle like this:

    if (container.open(in,  null) < 0) {  
        throw new IllegalArgumentException("could not open file: ");
    }

The problem happened when i use mp4 file and i passed to open a InputStream:

       InputStream in = new FileInputStream(filename);

In this case IContainer.open remains blocked and does not return anything.
However if I pass a file name to the open method or I use the flv format, it works fine. I have to use InputStream with an mp4 file.
Can someone help me to find the problem?

Sceik
  • 275
  • 1
  • 3
  • 13

2 Answers2

3

In case some other person runs across this issue, I'll say what I did that fixed my problem: Instead of opening from an InputStream, I opened the file directly used

if (container.open(filename, IContainer.Type.READ, null) < 0)
{
    throw new IllegalArgumentException("Could not open file: " + filename);
}

I hope this helps somebody that encounters this problem later. Cheers.

Shawn Blakesley
  • 1,743
  • 1
  • 17
  • 33
1

you need to use InputOutputStreamHandler e.g.

File initialFile = new File(filename);
        InputStream is = new FileInputStream(initialFile);
        InputOutputStreamHandler handler = new InputOutputStreamHandler(is);
        int result = container.open(handler, IContainer.Type.READ, null);
        if (result < 0)
            throw new IllegalArgumentException("could not open file: "
                    + filename);
rigby
  • 1,280
  • 3
  • 13
  • 21