Tan Tran Tan Tran - 6 days ago 5
Android Question

FFmpegFrameRecorder add text / image while recording

Does anyone know how to add text, image while recording video using FFmpegFrameRecorder from JavaCV? I have searched everywhere but got nothing

Answer

Read JAVCV example for add text in IplImage

FFmpegFrameRecorder recorder = null;

opencv_core.CvFont font = new opencv_core.CvFont(); 
opencv_core.cvInitFont(font, opencv_core.CV_FONT_HERSHEY_SCRIPT_SIMPLEX, 2.0, 2.0, 2, 2, opencv_core.CV_AA);
opencv_core.IplImage bgrImage = opencv_core.IplImage.create(width, height, IPL_DEPTH_8U, 3);;
//...
//init something(eg init recorder,init iplimage...)

opencv_core.cvPutText(bgrImage/*IplImage*/, "Text here", cvPoint(10,10), font, opencv_core.CvScalar.RED);
recorder.record(bgrImage);

or you can draw text on bitmap also record using FFmpegFrameRecorder

      Bitmap newImage = Bitmap.createBitmap(width, height, Config.ARGB_8888);
        Canvas c = new Canvas(newImage);
        c.drawBitmap(your_image_bitmap, 0, 0, null);
        Paint paint = new Paint();
        paint.setColor(Color.RED); 
        paint.setStyle(Style.FILL);                
        paint.setTextSize(20);
        c.drawText("Some Text", 0, 25, paint);
org.bytedeco.javacv.AndroidFrameConverter converter2 = new AndroidFrameConverter();
        Frame frames = converter2.convert(newImage );
        recorder.record(frames);