简体   繁体   English

从表面视图录制视频(绑定视频和相机预览)

[英]Record a video from surface view(bind video and camera preview)

I want to record video of whatever happens on surface.我想录制表面上发生的任何事情的视频。

I'm playing video on surface and showing camera preview over it.我正在 Surface 上播放视频并在上面显示相机预览。 I want to record both in one video and export as.mp4.我想在一个视频中同时录制并导出为 .mp4。 what should I do for it.我该怎么做。 your help would be much appreciated.非常感谢您的帮助。

在此处输入图像描述

Video and preview both are placed in one surface view.视频和预览都放在一个表面视图中。

(1) I'm highly recommend to refer grafika project from Google's repository in Github and try with RecordFBOActivity . (1) 我强烈建议您参考 Google 存储库中Github中的grafika项目并尝试使用RecordFBOActivity

(2) see EZFilter repositoey in Github . (2) 请参阅EZFilter中的EZFilter存储库。

and

(3) RecordableSurfaceview in Github (3) Github中的RecordableSurfaceview

May this will much helpful to you.愿这对你有很大帮助。

try this solution with your clip result which is getting in the segmentation result from ML kit.使用您的剪辑结果尝试此解决方案,该剪辑结果来自 ML 套件的分割结果。

@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;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM