Reputation: 477
I want to record video of whatever happens on surface.
I'm playing video on surface and showing camera preview over it. I want to record both in one video and export as .mp4. what should I do for it. your help would be much appreciated.
Video and preview both are placed in one surface view.
Upvotes: 2
Views: 1289
Reputation: 21
try this solution with your clip result which is getting in the segmentation result from ML kit.
@ColorInt
private Bitmap maskColorsFromByteBuffer(ByteBuffer byteBuffer, int maskWidth, int maskHeight) {
@ColorInt int[] colors = new int[maskWidth * maskHeight];
for (int i = 0; i < maskWidth * maskHeight; i++) {
float backgroundLikelihood = 1 - byteBuffer.getFloat();
if (backgroundLikelihood > 0.9) {
colors[i] = Color.GREEN;
} else if (backgroundLikelihood > 0.2) {
// Linear interpolation to make sure when backgroundLikelihood is 0.2, the alpha is 0 and
// when backgroundLikelihood is 0.9, the alpha is 128.
// +0.5 to round the float value to the nearest int.
int alpha = (int) (182.9 * backgroundLikelihood - 36.6 + 0.5);
colors[i] = Color.argb(alpha, 0, 255, 0);
}
}
Bitmap bitmap = Bitmap.createBitmap(maskWidth, maskHeight, this.bitmap.getConfig());
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(this.bitmap, 0, 0, p);
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
canvas.drawBitmap(Bitmap.createBitmap(colors, maskWidth, maskHeight, this.bitmap.getConfig()), 0, 0, p);
// canvas.drawPaint(p);
return bitmap;
}
Upvotes: 1
Reputation: 174
(1) I'm highly recommend to refer grafika project from Google's repository in Github and try with RecordFBOActivity
.
(2) see EZFilter
repositoey in Github.
and
(3) RecordableSurfaceview
in Github
May this will much helpful to you.
Upvotes: 2