Ffmpeg on Android

Text over Image using FFMPEG library on Android

I found a very simple and faster solution to this problem using Canvas on Android instead of using ffmpeg library.

Here is my code solution:

    ImageView mImageView = view.findViewById(R.id.imgView1);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.test);

Bitmap.Config config = bm.getConfig();
int width = bm.getWidth();
int height = bm.getHeight();

Bitmap newImage = Bitmap.createBitmap(width, height, config);

Canvas c = new Canvas(newImage);
c.drawBitmap(bm, 0, 0, null);

Paint paint = new Paint();
paint.setColor(Color.YELLOW);
paint.setStyle(Paint.Style.FILL);
paint.setTextSize(150);

c.drawText("Testare hai noroc", bm.getWidth()/3, bm.getHeight()/2, paint);

mImageView.setImageBitmap(newImage);

File file = new File("/storage/emulated/0/Download/",System.currentTimeMillis() + ".jpeg");

try {
newImage.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(file));
} catch (Exception e) {
e.printStackTrace();
}

I hope this solution will be useful to someone else.

How to use latest FFMPEG in Android Studio project?

There's a very easy solution for this, There's a precompiled library for android, as below https://github.com/WritingMinds/ffmpeg-android-java
Simply include this as a gradle project in your code and add few methods as per their documentation and you are done with FFMPEG commands in android.
This library is not very updated and have some missing features but still its good to use for many simple tasks.



Related Topics



Leave a reply



Submit