dean1990 / magiccamera Goto Github PK
View Code? Open in Web Editor NEWReal-time Filter Camera&VideoRecorder And ImageEditor With Face Beauty For Android---包含美颜等40余种实时滤镜相机,可拍照、录像、图片修改
Real-time Filter Camera&VideoRecorder And ImageEditor With Face Beauty For Android---包含美颜等40余种实时滤镜相机,可拍照、录像、图片修改
楼主,我很想知道你拍摄视频是怎么做到的,我没看到你调用拍摄相关的代码。
只看到一个MagicEngine这个类里面有startRecord()这个方法
然后我往里面看,就看不懂你怎么调用的了
能否详细解释一下录制视频如何实现的?
楼主,录制的视频保存在哪个文件下了?
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
^
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切换到后台再切换到前台后,拍摄的画面成了镜像的了
如标题,录制视频崩溃和拍摄的照片是黑色的。运行机型:魅族 魅蓝m3
以为更完善了,相册那里也添加了,结果两个项目导出来运行编译是一样的
下载代码,执行同步的时候报错
录制第二个视频结束的时候报错
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)
Pick a photo from gallery, not Working... can this be fixed
能否指导一下,你的视频录制+滤镜是如何实现的
28太高了啊,我25-27的,AS2.0+,编不过啊
拍出来的视频有点渣啊,请问有没有什么解决方案
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.