Giter VIP home page Giter VIP logo

uestccokey / ezfilter Goto Github PK

View Code? Open in Web Editor NEW
207.0 12.0 56.0 59.72 MB

A lightweight (<180KB), easy-to-extend Android filter and dynamic sticker framework for adding filters and stickers for camera, video, bitmap and view.(一个轻量级(<180KB)、易扩展的Android滤镜和动态贴纸框架,支持摄像头、视频、图片和视图添加滤镜和贴纸。)

License: MIT License

Java 99.51% GLSL 0.32% Kotlin 0.17%
filter gpu-image opengl offscreen-render shader opengl-es camera video bitmap

ezfilter's Introduction

Logo

EZFilter

A lightweight (<180KB), easy-to-extend Android filter and dynamic sticker framework for adding filters and stickers for camera, video, bitmap and view.

中文

Demo

Download

Screenshot

View加滤镜

Features

1.Support Camera, Camera2, Video, Bitmap and View add filters

2.Support Camera, Camera2, Video, Bitmap and View add dynamic stickers

3.Support recording video

4.Support screenshot

5.Support offscreen rendering

Sample

you can use EZFilter.input(xxx).addFilter(filter).into(view) to add filter and display.

EZFilter.input(bitmap)
        .addFilter(filter)
        .into(view);
EZFilter.input(video)
        .setLoop(true)
        .setVolume(0.5f)
        .addFilter(filter)
        .into(view);
EZFilter.input(camera)
        .addFilter(filter)
        .into(view);
EZFilter.input(camera2)
        .addFilter(filter)
        .into(view);
EZFilter.input(glview)
        .addFilter(filter)
        .into(view);

After calling the into method, you will get a RenderPipeline object, then you can use it for screenshots.

mPipeline.output(new BitmapOutput.BitmapOutputCallback() {
        @Override
        public void bitmapOutput(Bitmap bitmap){
        }
    }, true);
view.requestRender();
    // or
mPipeline.output(new BitmapOutput.BitmapOutputCallback() {
        @Override
        public void bitmapOutput(Bitmap bitmap){
        }
    }, width, height, true);
view.requestRender();

Other functions, such as recording videos, adding dynamic stickers, particle effects, etc., please refer to demo.

ezfilter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ezfilter's Issues

Camera Size According to screen(Full Screen SurfaceFitView)

My problem is that when I am using SurfaceFitView to fill my entire screen and changing the size to the size of the screen, the camera gives a vertically stretched view .
Screenshot 2020-04-22 at 11 04 52 AM

Result:
Img 1587535563926
You can see that the image is stretched vertically. So I do not know what to do anymore. So please any help in this matter will be appreciated. Please help me anyone.

Add Text

I want to add text in video and that text will animate on video with different animations. I tried it using FFMPEG But the output is not smooth. So i found your library

If you can help me in adding animating text in video and save it
Please reply asap

Video Saving issue

In some devices when save video and play video then video display like blank. and also after stop recording video directly not access , in cases if we access then ffmpeg give issue moov atom not found

App crash while record video in some devices

AndroidRuntime: FATAL EXCEPTION: MediaVideoEncoder
Process: asha.glich.effect, PID: 19849
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2392)
at cn.ezandroid.ezfilter.media.record.MediaEncoder.drain(MediaEncoder.java:223)
at cn.ezandroid.ezfilter.media.record.MediaEncoder.run(MediaEncoder.java:105)
at java.lang.Thread.run(Thread.java:818)

OffscreenVideo addFilterRender() method is not working

Hi,

I'm trying to save a video with the user's selected filter, when I run the below code I got a really weird behavior :

OffscreenVideo offscreenVideo = new OffscreenVideo(videoInputPath);
offscreenVideo.addFilterRender(currentFilter);
offscreenVideo.save(videoOutputPath);

The output :
Original video :

image

1 - For some reason, the input video change resolution and become smaller in the RenderView

Sans titre

2 - The video saved without any filter on it.

Thank you.

Crash when start recording after switched camera

First of all, I really liked these new features, but I'm having a crash issue when use function "startRecord()" after switching the camera using "switchCamera()" function.
It doesn't matter where the camera is facing at, it doesn't allow to use "startRecording()" after switching camera.
But without using the function, it's working well.
The app is using landscape mode setted under manifest (Maybe this is the problem?)

private void switchCamera() { try { mCurrentCameraId = (mCurrentCameraId + 1) % Camera.getNumberOfCameras(); } catch (Exception e){ Toast.makeText(this, "Can't switch camera", Toast.LENGTH_LONG).show(); } releaseCamera(); openCamera(mCurrentCameraId); }

https://pastebin.com/YE8jAqzx

Record error after using for a while

If mSupportRecord?.startRecording() == true -> works well
But after using for a while RecordableRender - mSupportRecord?.startRecording() == false -> dont work, I have to restart my app to work again

Compatibility errors

I've seen that in some devices tested by google play console, the app will crash only if he choose a filter that include double filters rendering.

image

"no main() in shader", but it exist

I don't know where is the problem 'cause is not the android version as you can see

image

MediaCodec.createInputSurface() IllegalStateException

I can't record the views
val renderPipeline = EZFilter.input(viewToRecord).addFilter(null) .enableRecord(path, true, false) .into(renderView) renderPipeline.setRenderSize(renderView.width, renderView.height) val recordSupported = renderPipeline.endPointRenders.find { glRender -> glRender is ISupportRecord } as? ISupportRecord return recordSupported

when i call startRecording() it return false, i debug the funcion and MediaCodec.createInputSurface() throw IllegalStateException
I try with version 2.0.7 and 2.0.6 with the same result but the app crashes directly for the same

Not Able to save the video

I am Not Able to save the video. When the video is saved, the directory show it as empty video file. Although it occupies proper space as of a video file, but it shows empty video.

Find drawable path string

I've tried many method to get path of my "noise.png" drawable for inputImage2 but no one works, can you explain me how to get it? Thanks in advance :)
image

Showing black screen only in View recording

When i add videoview in GLLinearLayout to record particular view and then only audio is working for video being displayed in videoview But video is not visible only it is showing black screen

<cn.ezandroid.ezfilter.view.glview.GLLinearLayout
android:id="@+id/gl_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:layout_centerInParent="true">

    <VideoView
        android:id="@+id/render_view_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_gravity="center"/>

</cn.ezandroid.ezfilter.view.glview.GLLinearLayout>

Can you please check So i can record view while playing video

Video saved without sound

Hi, after editing a video (from the gallery, not a recorded video) and saving it, it's saved with no sound, how to fix this issue?

Is there a problem here?

TIM截图20190325175203
if ((mBufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
mEncoder.signalEndOfInputStream();
mIsDecoderEOS = true;
mBufferInfo.size = 0;
}
Why do you need to end this? mEncoder.signalEndOfInputStream();

Low quality for higher FPS

I was testing my new shader that requires a big amount of GPU with very low camera FPS

https://pastebin.com/Up7wnUDZ (if you wanna try)

Is there a way on Android opengles of decrease rendering texture quality to boost FPS? Can you implement that option if there's a way?

How to get the camera frame before filter added?

Hi,it is a amazing library!
I want get the camera frame to do some image detectoin(example, detect face position then and dynamic sticker),but I have a confuse now,how to get every frame output by camera?
If someone have advise? very apprecite!

Bitmap: animated filters

I note that in Bitmap, animated filters doesn't work, returning a static filtered image.
If it's possible, make they works to record them will be a cool feature :)

Video importing orientation

Found an issue when importing a video to renderview, the mediaplayer doesnt work with video orientation: because when I import a video in landscape it works well, if is in potrait it will stretch.

screenshot_20180115-230308

Don't know if it's a non implemented feature or I missed something in my code, here it is:

image
image

Question on OpenCL

I saw your question on OpenCL on another repo leela-zero/leela-zero#1679

I have been trying to find examples of OpenCL on Android -- but so far not very promising.

Do you mind sharing some of your tutorial or code?

您好。

敝姓伍, 马来西亚华人, 祖籍广东。 这是我的领英帐号: https://www.linkedin.com/in/%E4%BC%8D%E6%A8%91%E7%9B%9B-%E5%8D%9A%E5%A3%AB-liang-ng-ph-d-0502822b/

我看到阁下在 Leela 有关 OpenCL 的提问, 并下载了 Ah Q 围棋 及 EZFilter , 非常佩服。

我花了好几个星期搜寻有关 Android OpenCL 的例子, 结果不是很满意。

不知阁下有没有公开的 Android OpenCL 教程或例子? 我们也可以洽谈咨询的费用。 请通过领英联系。

谢谢。

Set filter in MultiInput mode

Hi, your library is great.
However when I try to apply filter on left or right input in your MultiInputActivity, it doesn't use the effect.
Can you help me to solve this problem? Thank you a lot.

Purpose of EndPointRender ?

A question certainly from a newbie. As I see in the code there are 2 renders: a starting point render (FBORender) and an ending point render (EndPointRender). What is the idea behind EndPointRender ? does it enables you to record ?

Android Kitkat : Failed to stop the muxer

Video capturing through error on android kitkat device:

D/MPEG4Writer: Writer thread stopped W/System.err: java.lang.IllegalStateException: Failed to stop the muxer W/System.err: at android.media.MediaMuxer.nativeStop(Native Method) W/System.err: at android.media.MediaMuxer.stop(MediaMuxer.java:226) W/System.err: at app24.whtsappstatus.Camera.media.record.MediaMuxerWrapper.stop(MediaMuxerWrapper.java:121) W/System.err: at app24.whtsappstatus.Camera.media.record.MediaEncoder.release(MediaEncoder.java:168) W/System.err: at app24.whtsappstatus.Camera.media.record.MediaAudioEncoder.release(MediaAudioEncoder.java:89) W/System.err: at app24.whtsappstatus.Camera.media.record.MediaEncoder.run(MediaEncoder.java:105) W/System.err: at java.lang.Thread.run(Thread.java:841)

issue in stopRecording

When i start recording a view in ViewFilter Activity then It is giving me issues while i try to stop recording.
E/ACodec: [OMX.Exynos.AVC.Encoder] Unable to configure for node (err -22)
E/ACodec: [OMX.Exynos.AVC.Encoder] onCreateInputSurface returning error -22

Can you please help me with this.

Video merge issue.

Hi i am using MultipleInput Activity to mux 2 videos. For record audio of right size video i have enable audio recording as like below.

mRenderPipeline = EZFilter.input(builders, mTwoInput)
                 .enableRecord(videoPath, true, true)
                    .into(mRenderView, false);

now problem is it is also enable microphone audio.
so my question is how to merge multiple video with audio of right side video ??

Webview Issue in ViewFilter Activity

I am using ViewFilter Activity and In that i am using same WebView and When i am trying to play video in webview and it is not playing video in webview

glLayout.post(new Runnable() {
@OverRide
public void run() {
mRenderPipeline = EZFilter.input(glLayout)
.enableRecord("/sdcard/recordView.mp4", true, false)
.into(renderView);
for (GLRender render : mRenderPipeline.getEndPointRenders()) {
if (render instanceof ISupportRecord) {
mSupportRecord = (ISupportRecord) render;
}
}
}
});

When i comment above code it will play my video in webview

And in webview i am using
webView.setBackgroundColor(getResources().getColor(R.color.app_blue));
webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
Log.e("Here=", "onPageFinished");
view.loadUrl("javascript:(function() { document.getElementsByTagName('video')[0].play(); })()");
}
});
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("http://13.59.109.107/pixabay/videos/10276_1500364486.mp4");

Please let me know How can i play this video in webView ??

I need same functionality in my project

Please help me for this asap

Record bitmap from sequence image of camera TextureView

Hello, thank for amazing package.

private void changeBitmap() {
        if (mCurrentBitmap == mBitmap1) {
            mCurrentBitmap = mBitmap2;
        } else {
            mCurrentBitmap = mBitmap1;
        }

        mRenderPipeline = EZFilter.input(mCurrentBitmap)
                .addFilter(new LookupRender(RecordBitmapActivity.this, R.drawable.langman))
                .addFilter(new WobbleRender())
                .enableRecord("/sdcard/recordBitmap.mp4", true, false)
                .into(mRenderView);

        for (GLRender render : mRenderPipeline.getEndPointRenders()) {
            if (render instanceof ISupportRecord) {
                mSupportRecord = (ISupportRecord) render;
            }
        }
    }

The example above, mCurrentBitmap is getted from fix image.
Currently, I have Camera TextureView and do a segmentation frame from Camera TextureView into sequence bitmaps.

So how to pip every bitmap frames into mRenderPipeline = EZFilter.input(mCurrentBitmap) and record it?

How to use OffscreenImage?

Hi, I'm trying to use OffscreenImage, but I can't see anything in the bitmap, it is transparent.
My code is like the below:
val bitmapResult = EZFilter.input(resource).output(resource.width, resource.height)
where the resource is my image Bitmap, but nothing in the bitmapResult.
I'm trying to use your ImageFilterActivity.java, but it is the same when I uncomment this code.
`
// 截图方式一:不需要渲染在到View上便可以滤镜处理输出图像,图像默认宽高为输入图像的宽高
// Bitmap bitmap = EZFilter.input(mCurrentBitmap)
// .addFilter(new LookupRender(ImageFilterActivity.this, R.drawable.langman))
// .output();
// mPreviewImage.setImageBitmap(bitmap);

        // 截图方式二:需要渲染到View上后才能进行截图,图像默认宽高为View显示的宽高

`
CameraFilterActivity.java and CameraFilter2Activity.java take a screenshot is the same up.
I'm using Android 9.
Please help me! Thanks in advance!

SDK support very high

Hi, Why library have interface OnFilterRendersChangedListener, this supported starting with android N (24), how to lower min support version. thanks

Some devices are crashing while start record a portrait imported video

While testing app in certain devices, some crashes while start recording a portrait oriented video from camera or video saved by EZFilter (whatsapp doesn't crash for... reason?), that's same bug I was having months ago

Code for import:

 if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
            final List<String> paths = Matisse.obtainPathResult(data);
            if (!paths.isEmpty()) {
                String mimeType = URLConnection.guessContentTypeFromName(paths.get(0));
                if(mimeType.startsWith("video")) {
                    mRenderPipeline = EZFilter.input(Uri.parse(paths.get(0)))
                            .setLoop(true)
                            .into(mRenderView); 

Error appear when mRenderPipeline.startRecording to camera/ezfilter videos in portrait:

04-10 16:05:50.201 30626-30856/com.owner.filtertest E/ACodec: [OMX.Exynos.AVC.Encoder] failed to set input port definition parameters.
04-10 16:05:50.201 30626-30856/com.owner.filtertest E/ACodec:  configureCodec multi window instance fail  appPid : 30626
04-10 16:05:50.211 30626-30856/com.owner.filtertest E/ACodec: [OMX.Exynos.AVC.Encoder] configureCodec returning error -5001
    signalError(omxError 0x80001001, internalError -5001)
04-10 16:05:50.211 30626-30855/com.owner.filtertest E/MediaCodec: Codec reported err 0xffffec77, actionCode 0, while in state 3
04-10 16:05:50.211 30626-30626/com.owner.filtertest E/MediaCodec: configure failed with err 0xffffec77, resetting...
04-10 16:05:50.231 30626-30626/com.owner.filtertest E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.owner.filtertest , PID: 30626
    android.media.MediaCodec$CodecException: Error 0xffffec77
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:1778)
        at cn.ezandroid.ezfilter.media.record.MediaVideoEncoder.prepare(MediaVideoEncoder.java:60)
        at cn.ezandroid.ezfilter.media.record.MediaMuxerWrapper.prepare(MediaMuxerWrapper.java:40)
        at cn.ezandroid.ezfilter.media.record.RecordableEndPointRender.startRecording(RecordableEndPointRender.java:124)
        at cn.ezandroid.ezfilter.core.RenderPipeline.startRecording(RenderPipeline.java:634)
        at com.owner.filtertest .CameraActivity.startRecording(CameraActivity.java:690)
        at com.owner.filtertest .CameraActivity.bridge$lambda$0$CameraActivity(CameraActivity.java)
        at com.owner.filtertest .CameraActivity$$Lambda$3.run(Unknown Source)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:158)
        at android.app.ActivityThread.main(ActivityThread.java:7230)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

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.