Giter Site home page Giter Site logo

masayukisuda / gpuvideo-android Goto Github PK

View Code? Open in Web Editor NEW
642.0 21.0 174.0 58.28 MB

This library apply video filter on generate an Mp4 and on ExoPlayer video and Video Recording with Camera2.

License: MIT License

Java 100.00%
videoeditor video-processing video-filter android-library android-camera2 gpu mediacodec-api exoplayer2 gpuimage glsl-shaders

gpuvideo-android's Introduction

GPUVideo-android

Platform API

This library apply video filter on generate an Mp4 and on ExoPlayer video and Video Recording with Camera2.
Android MediaCodec API is used this library.

Features

  • apply video filter, scale, and rotate Mp4.
  • apply video filter on ExoPlayer video.
  • apply video filter on Video Recording with Camera2.

apply video filter on generate an Mp4


Sample Video
No filter

GlGlayScaleFilter
apply

GlMonochromeFilter
apply

GlWatermarkFilter
apply

apply video filter on ExoPlayer video

apply video filter on Video Recording with Camera2.

Gradle

Step 1. Add the JitPack repository to your build file

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.MasayukiSuda:GPUVideo-android:v0.1.2'
        // if apply video filter on ExoPlayer video
        implementation 'com.google.android.exoplayer:exoplayer-core:2.15.1'
}

Sample Usage apply video filter on generate an Mp4

    new GPUMp4Composer(srcMp4Path, destMp4Path)
            .rotation(Rotation.ROTATION_90)
            .size((width) 540, (height) 960)
            .fillMode(FillMode.PRESERVE_ASPECT_FIT)
            .filter(new GlFilterGroup(new GlMonochromeFilter(), new GlVignetteFilter()))
            .listener(new GPUMp4Composer.Listener() {
                @Override
                public void onProgress(double progress) {
                    Log.d(TAG, "onProgress = " + progress);
                }

                @Override
                public void onCompleted() {
                    Log.d(TAG, "onCompleted()");
                    runOnUiThread(() -> {
                        Toast.makeText(context, "codec complete path =" + destPath, Toast.LENGTH_SHORT).show();
                    });
                }

                @Override
                public void onCanceled() {
                    Log.d(TAG, "onCanceled");
                }

                @Override
                public void onFailed(Exception exception) {
                    Log.e(TAG, "onFailed()", exception);
                }
            })
            .start();

Builder Method

method description
rotation Rotation of the movie, default Rotation.NORMAL
size Resolution of the movie, default same resolution of src movie
fillMode Options for scaling the bounds of an movie. PRESERVE_ASPECT_FIT is fit center. PRESERVE_ASPECT_CROP is center crop , default PRESERVE_ASPECT_FIT
filter This filter is OpenGL Shaders to apply effects on video. Custom filters can be created by inheriting GlFilter.java. , default GlFilter(No filter). Filters is here.
videoBitrate Set Video Bitrate, default video bitrate is 0.25 * 30 * outputWidth * outputHeight
mute Mute audio track on exported video. Default mute = false.
flipVertical Flip Vertical on exported video. Default flipVertical = false.
flipHorizontal Flip Horizontal on exported video. Default flipHorizontal = false.

Sample Usage apply video filter on ExoPlayer video

STEP 1

Create SimpleExoPlayer instance. In this case, play MP4 file.
Read this if you want to play other video formats.

    TrackSelector trackSelector = new DefaultTrackSelector();

    // Measures bandwidth during playback. Can be null if not required.
    DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();
    // Produces DataSource instances through which media data is loaded.
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context, "yourApplicationName"), defaultBandwidthMeter);
    // This is the MediaSource representing the media to be played.
    MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(MP4_URL));

    // SimpleExoPlayer
    player = ExoPlayerFactory.newSimpleInstance(context, mediaSource);
    // Prepare the player with the source.
    player.prepare(videoSource);
    player.setPlayWhenReady(true);

STEP 2

Create GPUPlayerView and set SimpleExoPlayer to GPUPlayerView.

    gpuPlayerView = new GPUPlayerView(this);
    // set SimpleExoPlayer
    gpuPlayerView.setSimpleExoPlayer(player);
    gpuPlayerView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    // add gpuPlayerView to WrapperView
    ((MovieWrapperView) findViewById(R.id.layout_movie_wrapper)).addView(gpuPlayerView);
    gpuPlayerView.onResume();

STEP 3

Set Filter. Filters is here.
Custom filters can be created by inheriting GlFilter.java.

    gpuPlayerView.setGlFilter(new GlSepiaFilter());

Sample Usage apply video filter on Video Recording with Camera2.

SetUp on onResume method.

  sampleGLView = new GLSurfaceView(getApplicationContext());
  FrameLayout frameLayout = findViewById(R.id.wrap_view);
  frameLayout.addView(sampleGLView);
  
  gpuCameraRecorder = new GPUCameraRecorderBuilder(activity, sampleGLView)
    .lensFacing(LensFacing.BACK)
    .build();

Release on onPause method.

  sampleGLView.onPause();      

  gpuCameraRecorder.stop();
  gpuCameraRecorder.release();
  gpuCameraRecorder = null;

  ((FrameLayout) findViewById(R.id.wrap_view)).removeView(sampleGLView);
  sampleGLView = null;

Start and Stop Video record.

  // record start.
  gpuCameraRecorder.start(filepath);
  // record stop.
  gpuCameraRecorder.stop();

This filter is OpenGL Shaders to apply effects on camera preview. Custom filters can be created by inheriting GlFilter.java. , default GlFilter(No filter). Filters is here.

  gpuCameraRecorder.setFilter(GlFilter);

Other methods.

  // if flash enable, turn on or off camera flash. 
  gpuCameraRecorder.switchFlashMode();
  // autofocus change.
  gpuCameraRecorder.changeAutoFocus();
  // set focus point at manual.
  gpuCameraRecorder.changeManualFocusPoint(float eventX, float eventY, int viewWidth, int viewHeight); 
  // scale camera preview
  gpuCameraRecorder.setGestureScale(float scale);

Builder Method

method description
cameraRecordListener onGetFlashSupport, onRecordComplete, onError, and onCameraThreadFinish. Detail is here.
filter This filter is OpenGL Shaders to apply effects on camera preview. Custom filters can be created by inheriting GlFilter.java. , default GlFilter(No filter). Filters is here.
videoSize Resolution of the movie, default width=720, height=1280.
cameraSize Preview size.
lensFacing Select back or front camera. Default LensFacing.FRONT.
flipHorizontal Flip Horizontal on recorded video. Default flipHorizontal = false.
flipVertical Flip Vertical on recorded video. Default flipVertical = false.
mute Mute audio track on recorded video. Default mute = false.
recordNoFilter No Filter on recorded video although preview apply a filter. Default recordNoFilter = false.

Filters

  • Bilateral
  • BoxBlur
  • Brightness
  • BulgeDistortion
  • CGAColorspace
  • Contrast
  • Crosshatch
  • Exposure
  • FilterGroup
  • Gamma
  • GaussianBlur
  • GrayScale
  • Halftone
  • Haze
  • HighlightShadow
  • Hue
  • Invert
  • LookUpTable
  • Luminance
  • LuminanceThreshold
  • Monochrome
  • Opacity
  • Overlay
  • Pixelation
  • Posterize
  • RGB
  • Saturation
  • Sepia
  • Sharpen
  • Solarize
  • SphereRefraction
  • Swirl
  • ToneCurve
  • Tone
  • Vibrance
  • Vignette
  • Watermark
  • WeakPixelInclusion
  • WhiteBalance
  • ZoomBlur

References And Special Thanks to

Sample Dependencies

License

MIT License

ExoPlayer and ExoPlayer demo.

Copyright (C) 2014 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

gpuvideo-android's People

Contributors

alibabayev0 avatar eschmar avatar itome avatar jianinz avatar link184 avatar mansya avatar masayukisuda avatar pablogeek avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpuvideo-android's Issues

The performance is not very good

The performance is not very good when the mp4 is 4k and the android hardware is low.
I hope when preview with no filter, the performance run as well as origin

What are minimum and maximum values for filters?

I know:
-1f <= brightness <= 1f
0f <= contrast <= 4f

I want to know same about Saturation, Pixelation and Sharpen? Do they have any boundries?

If you could add such values for other filters as well, it would help me a lot.

Thank you for your work, Masayuki.

GlWhiteBalanceFilter does't work

An error occurred while using this filter:

Process: com.sm.stasversion, PID: 11011 java.lang.RuntimeException: Could not link program at com.daasuu.gpuv.egl.EglUtil.createProgram(EglUtil.java:61) at com.daasuu.gpuv.egl.filter.GlFilter.setup(GlFilter.java:77) at com.daasuu.gpuv.player.GPUPlayerRenderer.onDrawFrame(GPUPlayerRenderer.java:141) at com.daasuu.gpuv.egl.GlFrameBufferObjectRenderer.onDrawFrame(GlFrameBufferObjectRenderer.java:58) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270) 2019-11-18 14:55:18.931 11570-11570/? E/Zygote: isWhitelistProcess - Process is Whitelisted 2019-11-18 14:55:18.932 11570-11570/? E/Zygote: accessInfo : 1 2019-11-18 14:55:18.951 11570-11570/? E/android.dqagen: Not starting debugger since process cannot load the jdwp agent. 2019-11-18 14:55:18.964 11582-11582/? E/Zygote: isWhitelistProcess - Process is Whitelisted 2019-11-18 14:55:18.966 11582-11582/? E/Zygote: accessInfo : 1

Apparently, an error occurs in this place:

`public static int createProgram(final int vertexShader, final int pixelShader) throws GLException {
final int program = glCreateProgram();
if (program == 0) {
throw new RuntimeException("Could not create program");
}

    GLES20.glAttachShader(program, vertexShader);
    GLES20.glAttachShader(program, pixelShader);

    GLES20.glLinkProgram(program);
    final int[] linkStatus = new int[1];
    GLES20.glGetProgramiv(program, GL_LINK_STATUS, linkStatus, 0);
    if (linkStatus[0] != GL_TRUE) {
        GLES20.glDeleteProgram(program);
        throw new RuntimeException("Could not link program");
    }
    return program;
}` - EglUtil.java file.

In case of using a this filter, the pixelShader variable value = 0.

Thanks in advance.

GlFilterGroup squeezes the video resolution

Hey, thanks for this awesome library!

When I use the CLFilterGroup class, the size of the recorded video changes. It looks like the video is getting a vertical squeeze. The mp4 file has the right resolution though.

When I use the GLFilters separately everything works fine and there is no squeezing.

EDIT: I've found out that this issue only occurs when you add > 1 CLFilter to CLFilterGroup.

I expect the output video to be with filter and sound but i am getting the filtered video without sound.

I am creating a video player where after recording a video user should be able to apply gpu filter to the video then upload and then be able to play it.

I applied the GPUMp4Composer library but after applying the filter the video is coming as expected but the audio is getting muted.

**new GPUMp4Composer(srcMp4Path, destMp4Path)
.filter(new GlFilterGroup(FilterType.createGlFilter(filterTypes.get(select_postion), getApplicationContext())))
.listener(new GPUMp4Composer.Listener() {
@OverRide
public void onProgress(double progress) {

            }

            @Override
            public void onCompleted() {

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        progressDialog.dismiss();
                        GotopostScreen();
                    }
                });
            }

            @Override
            public void onCanceled() {
                Log.d("resp", "onCanceled");
            }

            @Override
            public void onFailed(Exception exception) {

                progressDialog.dismiss();
                Toast.makeText(Preview_Video_A.this, "Try Again", Toast.LENGTH_SHORT).show();

            }
        })
        .start();**

Crop Using Coordinates

Hi,

Thanks for the wonderfull library and it is great to see you merged all the other libraries you developed into one single library.

Is it possible to apply crop on the video using x , y coordinates and width and height?

Regards
Kerem Küsmezer

Saving fails on some devices

Saving a video using the MP4Composer fails on some devices, mostly Samsung Galaxy devices and Redmi. It ends in the OnFailed of the Mp4Composer, with exception.getMessage() returning null.

It also seems to only happen with some videos, on some devices. I have received a video which fails on one of those devices, but it works fine on my phone.

Any idea what could cause this? Unfortunately I don´t own any of those devices myself, so I am unable to dig deeper into the issue. It works fine on any device I have tested on.
I am using the library in my app and some users have reported this problem.

New logo/icon proposal

Good day sir. I am a graphic designer and i am interested in designing a logo for your good project. I will be doing it as a gift for free. I just need your permission first before I begin my design. Hoping for your positive feedback. Thanks

Cannot generate filtered 4k video

I got this error while trying to export a new filtered video from a 4k video.
2020-07-13 18:25:06.757 27802-27999/film.camera.vintage.rni E/MediaCodec: Codec reported err 0x80001009, actionCode 0, while in state 0 2020-07-13 18:25:06.773 27802-27991/film.camera.vintage.rni E/GPUMp4ComposerEngine: Could not shutdown mediaExtractor, codecs and mediaMuxer pipeline. java.lang.IllegalStateException at android.media.MediaCodec.native_stop(Native Method) at android.media.MediaCodec.stop(MediaCodec.java:2184) at com.daasuu.gpuv.composer.VideoComposer.release(VideoComposer.java:143) at com.daasuu.gpuv.composer.GPUMp4ComposerEngine.compose(GPUMp4ComposerEngine.java:248) at com.daasuu.gpuv.composer.GPUMp4Composer$1.run(GPUMp4Composer.java:173) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) 2020-07-13 18:25:06.799 27802-27968/film.camera.vintage.rni E/AndroidRuntime: FATAL EXCEPTION: GLThread 23797 Process: film.camera.vintage.rni, PID: 27802 java.lang.IllegalStateException: Could not get attrib or uniform location for aPosition at com.daasuu.gpuv.egl.filter.GlFilter.getHandle(GlFilter.java:158) at com.daasuu.gpuv.egl.filter.GlFilter.draw(GlFilter.java:114) at com.daasuu.gpuv.player.GPUPlayerRenderer.onDrawFrame(GPUPlayerRenderer.java:162) at com.daasuu.gpuv.egl.GlFrameBufferObjectRenderer.onDrawFrame(GlFrameBufferObjectRenderer.java:58) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1587) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1282) 2020-07-13 18:25:06.915 27802-28000/film.camera.vintage.rni E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7415be02a0 2020-07-13 18:25:06.915 27802-28000/film.camera.vintage.rni E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7415be0310

Has anyone ever gotten this error before?

FileNotFoundException

Hey! I'm getting file not found exception.

java.io.FileNotFoundException: acv/tone_cuver_sample.acv
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:376)
at android.content.res.AssetManager.open(AssetManager.java:350)
at d.e.a.h.d.c.a(:91)
at com.msp.postscheduler.views.imagefilter_screen.ImageFilterActivity$e$a.a(:453)
at com.msp.postscheduler.views.imagefilter_screen.FilterThumbnailsAdapter.a(:59)
at d.e.a.h.d.a.onClick(Unknown Source:6)
at android.view.View.performClick(View.java:6324)
at android.view.View$PerformClick.run(View.java:24993)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:192)
at android.app.ActivityThread.main(ActivityThread.java:6711)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)

The app is crashing on the release build with androidx

java.lang.AbstractMethodError: abstract method "void com.google.android.exoplayer2.video.VideoListener.onSurfaceSizeChanged(int, int)"
    at com.google.android.exoplayer2.SimpleExoPlayer.maybeNotifySurfaceSizeChanged(SimpleExoPlayer.java:1172)
    at com.google.android.exoplayer2.SimpleExoPlayer.setVideoSurface(SimpleExoPlayer.java:321)
    at com.daasuu.gpuv.player.GPUPlayerRenderer.onSurfaceCreated(GPUPlayerRenderer.java:94)
    at com.daasuu.gpuv.egl.GlFrameBufferObjectRenderer.onSurfaceCreated(GlFrameBufferObjectRenderer.java:38)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1551)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1279)

how to apply new GPUvideo

the same library for images is applying Instagram video i"m trying to apply them on the library like these 👍 https://github.com/imrunning/android-instagram-image-filter/tree/master/instagramfilter/src/main/java/jp/co/cyberagent/android/gpuimage/sample/filter

I'm trying to apply the IFImageFilter class for video like here

public class IFVideoFilter extends GlFilter {

    private int filterInputTextureUniform2;
    private int filterInputTextureUniform3;
    private int filterInputTextureUniform4;
    private int filterInputTextureUniform5;
    private int filterInputTextureUniform6;
    public int filterSourceTexture2 = EglUtil.NO_TEXTURE;
    public int filterSourceTexture3 = EglUtil.NO_TEXTURE;
    public int filterSourceTexture4 = EglUtil.NO_TEXTURE;
    public int filterSourceTexture5 = EglUtil.NO_TEXTURE;
    public int filterSourceTexture6 = EglUtil.NO_TEXTURE;
    private final LinkedList<Runnable> runOnDraw;
    private List<Integer> mResIds;
    private Context mContext;
    public IFVideoFilter(Context context,String fragmentShaderString){
        super(DEFAULT_VERTEX_SHADER,fragmentShaderString);
        mContext=context;
        runOnDraw = new LinkedList<>();
    }

    public void setup() {
        super.setup();
        filterInputTextureUniform2 = GLES20.glGetUniformLocation(getProgram(), "sTexture2");
        filterInputTextureUniform3 = GLES20.glGetUniformLocation(getProgram(), "sTexture3");
        filterInputTextureUniform4 = GLES20.glGetUniformLocation(getProgram(), "sTexture4");
        filterInputTextureUniform5 = GLES20.glGetUniformLocation(getProgram(), "sTexture5");
        filterInputTextureUniform6 = GLES20.glGetUniformLocation(getProgram(), "sTexture6");
        while (!runOnDraw.isEmpty()) {
            runOnDraw.removeFirst().run();
        }
        initInputTexture();

    }
    private void runOnDraw(final Runnable runnable) {
        synchronized (runOnDraw) {
            runOnDraw.addLast(runnable);
        }
    }
    public void onDestroy() {
        super.onDestroy();

        if (filterSourceTexture2 != EglUtil.NO_TEXTURE) {
            int[] arrayOfInt1 = new int[1];
            arrayOfInt1[0] = this.filterSourceTexture2;
            GLES20.glDeleteTextures(1, arrayOfInt1, 0);
            this.filterSourceTexture2 = EglUtil.NO_TEXTURE;
        }

        if (filterSourceTexture3 != EglUtil.NO_TEXTURE) {
            int[] arrayOfInt2 = new int[1];
            arrayOfInt2[0] = this.filterSourceTexture3;
            GLES20.glDeleteTextures(1, arrayOfInt2, 0);
            this.filterSourceTexture3 = EglUtil.NO_TEXTURE;
        }

        if (filterSourceTexture4 != EglUtil.NO_TEXTURE) {
            int[] arrayOfInt3 = new int[1];
            arrayOfInt3[0] = this.filterSourceTexture4;
            GLES20.glDeleteTextures(1, arrayOfInt3, 0);
            this.filterSourceTexture4 = EglUtil.NO_TEXTURE;
        }

        if (filterSourceTexture5 != EglUtil.NO_TEXTURE) {
            int[] arrayOfInt4 = new int[1];
            arrayOfInt4[0] = this.filterSourceTexture5;
            GLES20.glDeleteTextures(1, arrayOfInt4, 0);
            this.filterSourceTexture5 = EglUtil.NO_TEXTURE;
        }

        if (filterSourceTexture6 != EglUtil.NO_TEXTURE) {
            int[] arrayOfInt5 = new int[1];
            arrayOfInt5[0] = this.filterSourceTexture6;
            GLES20.glDeleteTextures(1, arrayOfInt5, 0);
            this.filterSourceTexture6 = EglUtil.NO_TEXTURE;
        }

    }
    @Override
    protected void onDrawArraysPre() {
        super.onDrawArraysPre();

        if (filterSourceTexture2 != EglUtil.NO_TEXTURE) {
            GLES20.glActiveTexture(GLES20.GL_TEXTURE3);
            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, filterSourceTexture2);
            GLES20.glUniform1i(filterInputTextureUniform2, 3);
        }

        if (filterSourceTexture3 != EglUtil.NO_TEXTURE) {
            GLES20.glActiveTexture(GLES20.GL_TEXTURE4);
            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, filterSourceTexture3);
            GLES20.glUniform1i(filterInputTextureUniform3, 4);
        }

        if (filterSourceTexture4 != EglUtil.NO_TEXTURE) {
            GLES20.glActiveTexture(GLES20.GL_TEXTURE5);
            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, filterSourceTexture4);
            GLES20.glUniform1i(filterInputTextureUniform4, 5);
        }

        if (filterSourceTexture5 != EglUtil.NO_TEXTURE) {
            GLES20.glActiveTexture(GLES20.GL_TEXTURE6);
            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, filterSourceTexture5);
            GLES20.glUniform1i(filterInputTextureUniform5, 6);
        }

        if (filterSourceTexture6 != EglUtil.NO_TEXTURE) {
            GLES20.glActiveTexture(GLES20.GL_TEXTURE7);
            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, filterSourceTexture6);
            GLES20.glUniform1i(filterInputTextureUniform6, 7);
        }

    }

    public void addInputTexture(int resId) {
        if (mResIds == null) {
            mResIds = new ArrayList<Integer>();
        }
        mResIds.add(resId);
    }

    public void initInputTexture() {
        if (mResIds == null) {
            return;
        }
        if (mResIds.size() > 0) {
            runOnDraw(new Runnable() {
                @Override
                public void run() {
                    Bitmap b = BitmapFactory.decodeResource(mContext.getResources(), mResIds.get(0));
                    filterSourceTexture2 = EglUtil.loadTexture(b, EglUtil.NO_TEXTURE, true);
                }
            });
        }

        if (mResIds.size() > 1) {
            runOnDraw(new Runnable() {
                @Override
                public void run() {
                    Bitmap b = BitmapFactory.decodeResource(mContext.getResources(), mResIds.get(1));
                    filterSourceTexture3 = EglUtil.loadTexture(b, EglUtil.NO_TEXTURE, true);
                }
            });
        }

        if (mResIds.size() > 2) {
            runOnDraw(new Runnable() {
                @Override
                public void run() {
                    Bitmap b = BitmapFactory.decodeResource(mContext.getResources(), mResIds.get(2));
                    filterSourceTexture4 = EglUtil.loadTexture(b, EglUtil.NO_TEXTURE, true);
                }
            });
        }

        if (mResIds.size() > 3) {
            runOnDraw(new Runnable() {
                @Override
                public void run() {
                    Bitmap b = BitmapFactory.decodeResource(mContext.getResources(), mResIds.get(3));
                    filterSourceTexture5 = EglUtil.loadTexture(b, EglUtil.NO_TEXTURE, true);
                }
            });
        }

        if (mResIds.size() > 4) {
            runOnDraw(new Runnable() {
                @Override
                public void run() {
                    Bitmap b = BitmapFactory.decodeResource(mContext.getResources(), mResIds.get(4));
                    filterSourceTexture6 = EglUtil.loadTexture(b, EglUtil.NO_TEXTURE, true);
                }
            });
        }
    }


}

i get error
java.lang.RuntimeException: Could not link program
Player is accessed on the wrong thread.

Video file not ready

CameraRecodListener.onRecordComplete() is called before the video file is prepared by native codecs logic. As result the file is broken when we try to use it exactly after onRecordComplete() #24

hi i am getting this error when i am generating signed Apk

Type com.daasuu.gpuv.camerarecorder.CameraHandler is defined multiple times: E:\VELE VIDEOS\My APP\app\build\intermediates\project_dex_archive\release\out\com\daasuu\gpuv\camerarecorder\CameraHandler.dex, E:\VELE VIDEOS\My APP\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex

issue on saving

Hi, Thank you for this amazing library!

However, I just run sample app of this project, and found that if I follow the flow below, causes error.
movie preview --> select filter(bilateral_blur/box_blur/brightness etc) --> touch save button

    Process: com.daasuu.gpuvideoandroid, PID: 12432
    java.lang.IllegalStateException: Could not get attrib or uniform location for center
        at com.daasuu.gpuv.egl.filter.GlFilter.getHandle(GlFilter.java:153)
        at com.daasuu.gpuv.egl.filter.GlBulgeDistortionFilter.onDraw(GlBulgeDistortionFilter.java:77)
        at com.daasuu.gpuv.egl.filter.GlFilter.draw(GlFilter.java:121)
        at com.daasuu.gpuv.player.GPUPlayerRenderer.onDrawFrame(GPUPlayerRenderer.java:162)
        at com.daasuu.gpuv.egl.GlFrameBufferObjectRenderer.onDrawFrame(GlFrameBufferObjectRenderer.java:58)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)

These are the error logs,
and this is caused because below two methods returns -1

GLES20.glGetAttribLocation(program, name);
GLES20.glGetUniformLocation(program, name);

Do you have any idea that I can fix this issue?

Rotate GPUPlayerView

I did apply 90 rotation on Exoplayer view but after applying filter i have to rotate GPUPlayerView also.
How can rotate GPUPlayerView?
Please guide.

Samsung P-600 and several others - broken aspect ratio

Hi!

I've encountered an issue with Samsung P600: attaching screenshots for portrait and landscape rotation (with configuration change on rotation disabled) in the mentioned order:

1
2

I think that the issue is that this device's display has rotation equal to Surface.ROTATION_270 in portrait orientation.

I've tried to add a workaround with a check of device orientation and returning 90 in portrait mode if the rotation is either 90 or 270, but then the aspect ratio will be calculated wrong (1.(7) instead of 0.5625 for 16:9). To work this around the preview shader can be copied and changed with resizing Y instead of X by this value. Still, when the filter is applied and recording is started - all is just broken for preview... If I'll find the solution first - I'll make a fix and PR, but I haven't found it yet.

P.S.: thanks for such an enormous job, for most cases it is awesome

Best Regards,
Andrey

camera record issue

When I set filter to record, the viewport will be change!
camera -> select filter - > record start

When adding water mark by GPU using service, it doest not stop service when stopping service

When adding water mark by GPU using service, it doest not stop service when stopping service

call gpuMp4Composer.cancel(); but not stop.

gpuMp4Composer = null;
gpuMp4Composer = new GPUMp4Composer(filePath_local , file_path)
		.filter(new GlWatermarkFilter(image, GlWatermarkFilter.Position.RIGHT_BOTTOM))
		.listener(new GPUMp4Composer.Listener() {
			@Override
			public void onProgress(double progress) {
				double value = progress * 100;
			}
			@Override
			public void onCompleted() {				
			}
			@Override
			public void onCanceled() {				
			}
			@Override
			public void onFailed(Exception exception) {				
			}
		})
		.start();

Application not able to record video on Samsung J series mobiles

My application is working on all the devices of samsung, But not working on samsung J series mobile. Not able to record video on those phone. Application starts the camera on recording, make a file of a video inside memory. but when i stop recording that video doesnot play. even i go through from memory and got 0KB file inside memory.Getting below error

): selectVideoCodec:
05-14 08:14:38.643 I/MediaVideoEncoder( 1784): codec:OMX.Exynos.AVC.Encoder,MIME=video/avc
05-14 08:14:38.643 I/MediaVideoEncoder( 1784): selectColorFormat:
05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.643 I/OMXMaster( 2432): makeComponentInstance(OMX.Exynos.avc.dec) in mediacodec process
05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.643 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706433 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc
05-14 08:14:38.644 W/VideoCapabilities( 1784): Unrecognized profile 2130706434 for video/avc05-14 08:14:38.645 D/libexynosv4l2( 2432): try node: /dev/video605-14 08:14:38.646 I/libexynosv4l2( 2432): node found for device s5p-mfc-dec: /dev/video6

Please help

After rotation video frame will be square. Not show proper as per aspect ratio

@MasayukiSuda I have rotated video frames but it should not display properly.
I have used video of 16/9 aspect ratio. Then apply filter on it. It will show proper for 0 and 180 roation. But if rotation will be 90 or 270 then frame size is not proper. I did not rotate GPUPlayerView. But I rotate frames while draw it. But After rotation frame width will change. I have checked aspect ration after rotation, it is proper. If aspect ration is proper then why frame is not show proper.

Please guide me.

preview issue

when i set filter than try to record video preview not showing on full screen

get black photo when capture photo

Hi,
Thank you for powerful library.
I have a issue. when i capture photo from camera, all of camera screen (Square, portrait, landscape), the result i receive is black photo. it was occurred on huawei, xiaomi device but other device was not.
Sorry for my bad english.
Regards.

landscape video recording not working (wrong aspect ratio, video cropped)

Hello,

Thanks for sharing this project.

I tried to record video in landscape orientation with the sample app, and the result is wrong ratio aspect and cropped video.

I tried with 3 different devices which gave me the same output results (s7, lg G6, huawei p9).

Everything is working fine in the portait mode, but in landscape camera preview is a little bit streched (with some zoom ?), and the output is completly streched and cropped. I tried to manually set width, height, ratio, rotation, but with no success...

Regards

videoSize and CameraSize

Can you please explain the use for video size and cameraSize. i have set both to 1080 * 720 in a landscape mode activity to record video. but when it is saved the video is very stretchy. I think i have not put it properly.

LandscapeCameraActivity

video-sizeとcamera-sizeは同じですが、ビデオファイルを入手して、画面が引き伸ばされました。どう解決しますか?

Camera quality

Camera Quality is less as compared to the original mobile camera and can we make it the same as the quality of original camera or quality like tiktok camera

Video content length is zero

Integrate GPUVideo-android with our app, the video file was successfully generated with reasonable size, although when opening it via VLC or QuickTime Player, the duration/content length says 00:00.

Any ideas?

Library Version: 0.1.1
Phone: Google Pixel 2

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.