Sceik
Sceik

Reputation: 275

Xuggler: IContainer.open() blocks

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?

Upvotes: 5

Views: 975

Answers (2)

rigby
rigby

Reputation: 1430

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);

Upvotes: 1

Shawn Blakesley
Shawn Blakesley

Reputation: 1903

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.

Upvotes: 3

Related Questions