0

I’m working with Xuggler and trying to create a program that uses frames that are captured from video.

I found this code: Xuggler: Deocde And Capture Frames

I managed to get it working and saving the frames I needed.

Now, I’m trying to integrate it into my GUI program on a separate thread to keep everything from locking up while it grabs the frames. I pretty much just copied everything in main into the run method. The only changes I made were to correct for the args filename. I hard coded it, and I checked in my working program to be sure it was the correct path.

Now, when I try to run the frame grabbing code in its own Runnable thread, it crashes. It seems to crash at this section when opening the file:

IContainer container = IContainer.make();

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

After some research around the Xuggler site, I looked at the open method for the IContainer file here: Xuggler: IContainer API open()

It says “If the current thread is interrupted while this blocking method is running the method will return with a negative value. “</p>

It does return a negative value before it crashes, so I thought this might be my problem. Though, this is the only extra thread currently running in my program. My program is just some basic frames and panels that I'm going to use to display stuff. Then, after creating those, I try to start the frame grabbing thread which crashes.

I’m not sure how to get around this. Could someone point me in the right direction? Thanks.

Edit:

After finding this post: Well, I don't have enough rep to post a third link, so it can be found by googling: icontainer.open xuggler-users

I implemented opening the container using the other open method that required a format and it seemed to work.

Now, it throws this exception when it gets to this section:

resampler = IVideoResampler.make(
        videoCoder.getWidth(), videoCoder.getHeight(), IPixelFormat.Type.BGR24,
        videoCoder.getWidth(), videoCoder.getHeight(), videoCoder.getPixelType());
      if (resampler == null)
        throw new RuntimeException(
          "could not create color space resampler for: " + filename);

I tried opening it by setting my own IFormat like so:

IContainerFormat format = IContainerFormat.make();        
        format.setInputFormat("mp4");

And I tried using null as the format like the API says to have the class "guess" the format.

Both throw the same exception though, so I'm not sure where to go from here. I'm still searching though.

4

1 回答 1

0

也许您应该使用ExecutorService来处理线程池。

于 2013-04-07T05:04:02.637 回答