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
Android Marshmallow Request Permission
How to Use Putextra() and Getextra() For String Data
How to Get Current Time and Date in Android
How to Use Recyclerview Inside Nestedscrollview
Integrating the Zxing Library Directly into My Android Application
How to Adjust Text Font Size to Fit Textview
Sending an Intent to Browser to Open Specific Url
How to Transfer Some Data to Another Fragment
Detect Home Button Press in Android
Firebaseinstanceidservice Is Deprecated
Android Soft Keyboard Covers Edittext Field
Close Application and Launch Home Screen on Android
Null Pointer Exception - Findviewbyid()
How to Load an Imageview by Url in Android
Android "Only the Original Thread That Created a View Hierarchy Can Touch Its Views."