Git Product home page Git Product logo

magiccamera's Issues

拍摄视频问题

楼主,我很想知道你拍摄视频是怎么做到的,我没看到你调用拍摄相关的代码。
只看到一个MagicEngine这个类里面有startRecord()这个方法
然后我往里面看,就看不懂你怎么调用的了
能否详细解释一下录制视频如何实现的?

Not effect filter after save bitmap

I have applied filter -> View on the Surface is ok, but when I save the bitmap to image, not have the filter?

public void getBitmapWithFilter(final Bitmap bitmap, final File outFile, final OnBitmapReceiveListener onBitmapReceiveListener){
        if (!mIsSaving) {
            mIsSaving = true;
            mGLSurfaceView.queueEvent(new Runnable() {
                @Override
                public void run() {
                    int width = bitmap.getWidth();
                    int height = bitmap.getHeight();

                    if(mFilter != null) {
                        mFilter.onInputSizeChanged(width, height);
                        mFilter.onDisplaySizeChanged(width, height);
                    }

                    // init buffer for texture
                    int[] mFrameBuffers = new int[1];
                    int[] mFrameBufferTextures = new int[1];

                    // load texture
                    OpenGlUtils.loadTextureBufferFiltering(mFrameBuffers, mFrameBufferTextures, width, height);
                    GLES20.glViewport(0, 0, width, height);

                    // load texture with bitmap
                    int textureId = OpenGlUtils.loadTexture(bitmap, OpenGlUtils.NO_TEXTURE, false);

                    // draw frame to texture
                    if(mFilter != null){
                        mFilter.onDrawFrame(textureId);
                    } else {
                        imageInput.onDrawFrame(textureId);
                    }

                    // copy pixel buffer from the current texture
                    Bitmap result = BitmapProcessor.getBitmapFromTexture(mFrameBuffers[0], textureId, width, height);

                    // delete texture
                    OpenGlUtils.deleteTextureBufferFiltering(textureId, mFrameBuffers, mFrameBufferTextures);

                    // rest getBitmapWithFilter display
                    if(mFilter != null) {
                        mFilter.onDisplaySizeChanged(mSurfaceWidth, mSurfaceHeight);
                        mFilter.onInputSizeChanged(mImageWidth, mImageHeight);
                    }

                    if (outFile != null) {
                        // save bitmap to disk
                        BitmapProcessor.saveBitmap(result, outFile);
                    }

                    mIsSaving = false;
                    // reset viewport of the current texture.
                    GLES20.glViewport(0, 0, mSurfaceWidth, mSurfaceHeight);

                    // notice to activity
                    if (onBitmapReceiveListener != null) {
                        onBitmapReceiveListener.onBitmapReceive(result);
                    }
                }
            });
        }
    }

public static Bitmap getBitmapFromTexture(int mFrameBuffers, int mFrameBufferTextures, final int width, final int height) {
        final Bitmap object[] = new Bitmap[1];
        try {
            GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffers);
            GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mFrameBufferTextures, 0);
            GLES20.glClear(0);
            object[0] = createBitmap(width, height);
            GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
            GLES20.glClear(0);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return object[0];
    }

public static Bitmap createBitmap(int width, int height) {
        ByteBuffer ib = ByteBuffer.allocate(width * height * 4);
        ib.order(ByteOrder.LITTLE_ENDIAN);

        GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib);
        ib.rewind();

        Bitmap resultTemp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        resultTemp.copyPixelsFromBuffer(ib);

        return resultTemp;
    }

public static void loadTextureBufferFiltering(int[] mFrameBuffers, int[] mFrameBufferTextures, int width, int height) {
        GLES20.glGenFramebuffers(1, mFrameBuffers, 0);
        GLES20.glGenTextures(1, mFrameBufferTextures, 0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mFrameBufferTextures[0]);
        GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffers[0]);
        //Bind the texture to your FBO
        GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mFrameBufferTextures[0], 0);
    }

    public static void deleteTextureBufferFiltering(int textureId, int[] mFrameBuffers, int[] mFrameBufferTextures) {
        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
        GLES20.glDeleteTextures(1, new int[]{textureId}, 0);
        GLES20.glDeleteFramebuffers(mFrameBuffers.length, mFrameBuffers, 0);
        GLES20.glDeleteTextures(mFrameBufferTextures.length, mFrameBufferTextures, 0);
    }

编译错误

Androidstudio 3.1.3
编译出现以下错误

See file:///D:/codesource/demo/openGL/MagicCamera-master/Project-AndroidStudio/magicfilter/build/tmp/compileMagicBeautifyArm64-v8aReleaseSharedLibraryMagicBeautifyArm64-v8aReleaseSharedLibraryMainCpp/output.txt for all output for compileMagicBeautifyArm64-v8aReleaseSharedLibraryMagicBeautifyArm64-v8aReleaseSharedLibraryMainCpp.
compiling Conversion.cpp failed.
In file included from D:\codesource\demo\openGL\MagicCamera-master\Project-AndroidStudio\magicfilter\src\main\jni\bitmap\Conversion.h:4:0,
from D:\codesource\demo\openGL\MagicCamera-master\Project-AndroidStudio\magicfilter\src\main\jni\bitmap\Conversion.cpp:1:
D:\Android\sdk\ndk-bundle\sources\cxx-stl\stlport\stlport/stdio.h:35:46: fatal error: ../include/stdio.h: No such file or directory

include _STLP_NATIVE_C_HEADER(stdio.h)

                                          ^

compilation terminated.

compiling MagicBeautify.cpp failed.
In file included from D:\codesource\demo\openGL\MagicCamera-master\Project-AndroidStudio\magicfilter\src\main\jni\beautify\MagicBeautify.h:4:0,
from D:\codesource\demo\openGL\MagicCamera-master\Project-AndroidStudio\magicfilter\src\main\jni\beautify\MagicBeautify.cpp:1:
D:\codesource\demo\openGL\MagicCamera-master\Project-AndroidStudio\magicfilter\src\main\jni\beautify../bitmap/JniBitmap.h:3:28: fatal error: android/bitmap.h: No such file or directory
#include <android/bitmap.h>
^
compilation terminated.

compiling BitmapOperation.cpp failed.
In file included from D:\codesource\demo\openGL\MagicCamera-master\Project-AndroidStudio\magicfilter\src\main\jni\bitmap\BitmapOperation.cpp:1:0:
D:\codesource\demo\openGL\MagicCamera-master\Project-AndroidStudio\magicfilter\src\main\jni\bitmap\BitmapOperation.h:4:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.

compiling MagicJni.cpp failed.
D:\codesource\demo\openGL\MagicCamera-master\Project-AndroidStudio\magicfilter\src\main\jni\MagicJni.cpp:1:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.

Finished compileMagicBeautifyArm64-v8aReleaseSharedLibraryMagicBeautifyArm64-v8aReleaseSharedLibraryMainCpp, see full log file:///D:/codesource/demo/openGL/MagicCamera-master/Project-AndroidStudio/magicfilter/build/tmp/compileMagicBeautifyArm64-v8aReleaseSharedLibraryMagicBeautifyArm64-v8aReleaseSharedLibraryMainCpp/output.txt.

美颜问题

项目中的美颜,有jni和shader两种实现方式。但是我测试后发现,即使我将jni和shader全部注释掉,依然可以进行美颜。很奇怪,rebuild或者删掉生成的.so文件或者注释掉.so文件的加载代码,代码依然可以神奇的正常运行,进行美颜。简言之,就是我现在确定不了作者到底是通过哪种方式实现美颜的。。。因为现在在研究美颜问题,如果您有任何建议请告知,谢谢。

镜像问题

将app切换到后台再切换到前台后,拍摄的画面成了镜像的了

连续录制视频崩溃

录制第二个视频结束的时候报错

 com.seu.magicfilter.encoder.video.TextureMovieEncoder.stopRecording(TextureMovieEncoder.java:168)
com.seu.magicfilter.widget.MagicCameraView.onDrawFrame(MagicCameraView.java:126)
android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1548)
android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)

视频问题

拍出来的视频有点渣啊,请问有没有什么解决方案

怎么引用magicFilter啊?引入工程报错

Caused by: java.io.IOException: Cannot run program "/Users/dean/Dev/android-sdk/cmake/3.6.4111459/bin/cmake" (in directory "C:\Users\Administrator\Desktop\eeee\magicfilter"): CreateProcess error=2, 系统找不到指定的文件。

您是怎么编译通过呢

录制视频崩溃

真机OPPO r15梦境版 安卓9.0
美颜录制视频闪退

E/AndroidRuntime: FATAL EXCEPTION: TextureMovieEncoder
    Process: seu.com.magiccamera, PID: 5104
    android.media.MediaCodec$CodecException: Error 0xfffffc0e
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:1960)
        at android.media.MediaCodec.configure(MediaCodec.java:1889)
        at com.seu.magicfilter.encoder.video.VideoEncoderCore.<init>(VideoEncoderCore.java:81)
        at com.seu.magicfilter.encoder.video.TextureMovieEncoder.prepareEncoder(TextureMovieEncoder.java:407)
        at com.seu.magicfilter.encoder.video.TextureMovieEncoder.handleStartRecording(TextureMovieEncoder.java:324)
        at com.seu.magicfilter.encoder.video.TextureMovieEncoder.access$000(TextureMovieEncoder.java:65)
        at com.seu.magicfilter.encoder.video.TextureMovieEncoder$EncoderHandler.handleMessage(TextureMovieEncoder.java:293)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:232)
        at com.seu.magicfilter.encoder.video.TextureMovieEncoder.run(TextureMovieEncoder.java:259)
        at java.lang.Thread.run(Thread.java:764)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.