IPValverde
IPValverde

Reputation: 2029

Grab Frame VideoToGif in Android

I'm trying to grab frames from an Video file in android, the only alternative (tha is already compiled an ready for use) is the videoToGif Project. It uses JavaCV, JavaCpp and Java SE inside Android! The final apk is really big, but I'm doing just an academic project...

ERROR I'm using the follow code:

ModifiedFrameGrabber frameGrabber = new ModifiedFrameGrabber(VIDEO_PATH);
IplImage frame = null;

try
{
    frameGrabber.start();
    frame = frameGrabber.grab();
} catch(Exception e){...}

byte[] data = frame.getByteBuffer().array();

In the last line I get the error:

Caused by: java.lang.UnsupportedOperationException
    at java.nio.DirectByteBuffer.protectedArray(DirectByteBuffer.java:292)
    at java.nio.ByteBuffer.array(ByteBuffer.java:144)
    at my.package.onCreate(MyClass:x)

Anyone can help me with that? It seems that the proble is in Java API...

Upvotes: 1

Views: 852

Answers (1)

Samuel Audet
Samuel Audet

Reputation: 4994

Direct NIO buffers don't have an array. Call get() instead of array().

Upvotes: 4

Related Questions