Quack-Ware.com Free Software & Tutorials

11Oct/117

Include FFMpeg in Android and grab a frame from a 3gp video.

Thought I would write about the recent pain I experienced in trying to get FFMpeg into Android and subsequently grab a frame from a video. Hopefully this tutorial will help out a bunch of people, so anyway here we go.

 

The first thing you are going to want to get is JavaCV (Website here) and follow the EXACT instructions under "Quick Start for OpenCV"

 

If you followed the instructions you should have 2 jar files in your build path along with a large amount of .so files in your libs/armeabi folder. Now the class you are going to be looking at is called "FFMpegFrameGrabber" (Code here). Here is some sample code to give you a general idea of how to grab a frame from your video.

//Path is the path to your .3gp or whatever file on your sdcard
FrameGrabber f = new FFMpegFrameGrabber(path);
f.start();
IplImage _image = f.grab();
//We need to convert from 3 channels to 4 channels so that we can convert
//from IplImage to Bitmap
IplImage image = IplImage.create(return_image.width() ,return_image.height(),IPL_DEPTH_8U,4);
//source, dest, code
cvCvtColor(_image,image,CV_BGR2RGBA);
int width = image.width();
int height = image.height();
Bitmap b = Bitmap.createBitmap(width,height, Config.ARGB_8888);
//Make sure you use getByteBuffer()!
b.copyPixelsFromBuffer(image.getByteBuffer());
//MAKE SURE YOU DO NOT CALL stop() BEFORE YOU CREATE A BITMAP FROM IMAGE
f.stop();

You might see an error about cvCvtColor, in which case you need to add the following in your import statements:

import static com.googlecode.javacv.cpp.opencv_imgproc.*;

Now you can display your new bitmap in whichever way you want.

Tagged as: , , 7 Comments
16Aug/113

Inheritance, Abstract Classes, and Interfaces – C# C Sharp Visual Studio 2010

In this tutorial I show you how to use inheritance, abstract classes, and interfaces and talk about how they help your programming style. WEBSITE: www.Quack-Ware.com FREE CODE SNIPPETS http

28Jul/111

Properties & Indexers – C# C Sharp Visual Studio 2010

In this tutorial I show you how to create properties for your C# class along with having indexers into the class. WEBSITE: www.Quack-Ware.com FREE CODE SNIPPETS http

18Dec/100

Start, Stop, & List Processes – C# C Sharp Visual Studio 2010

In this tutorial I show you how to start, stop, and list processes from your machine. You can create a

14Nov/100

BubbleSort in C# – C# C Sharp Visual Studio 2010

In this tutorial I show you how to implement the O(n^2) sorting algorithm bubblesort in c sharp. WEBSITE: www.Quack-Ware.com FORUMS

12Nov/100

LinkedList From Scratch PART 2 – C# C Sharp Visual Studio 2010

In this tutorial I show you how to create your own linked list similar to the List in C# from

12Nov/100

LinkedList From Scratch PART 1 – C# C Sharp Visual Studio 2010

In this tutorial I show you how to create your own linked list similar to the List in C# from

11Nov/100

Find the Palindrome – ACM Contest Algorithm Series – C# C Sharp Visual Studio 2010

In this tutorial I show you how to find a palindrome given an input number. This is the first video

9Jul/100

How to Publish an Application – C# C Sharp Visual Studio 2010

In this tutorial I show you several different methods on how to publish your latest and greatest application from Visual

12Jun/100

How to Create an Application that Checks for Updates PART 2 – C# C Sharp Visual Studio 2010

In this tutorial I show you how to create an application that has a feature to check for updates and