Grab Frame VideoToGif in Android

850 views Asked by At

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...

1

There are 1 answers

1
Samuel Audet On BEST ANSWER

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