This library uses OpenGL Shaders to apply effects on Videos at Runtime

Related tags

Media VidEffects
Overview

VidEffects

Android Arsenal

This is an Android library which can be used to apply different Filters/Effects on videos. It uses vertexShaders and fragmentShaders to apply effects on GLSurfaceView. It uses MediaPlayer instance for playing videos on GlSurfaceView. See the sample app in order to see a working demo.

Img

Change Log

1.1.0 - Added ability to save video once you apply a FILTER (not EFFECT), Updated Sample app with a detailed example, 

Supported Effects

The following list of effects are currently avaialble and can be applied using VidEffects

Limitations

  • The effects applied using this library are temporary. What that means is that the original video doesn't change. Effects are only applied during video playback and once the video ends the effects end with it.
  • Minimum Supported Android version is 21 (Lollipop)
  • Saving video available only for Filters and requires Android 23 min api version.For more information check the file VideoController.
  • Other ways to save video once effect/filter is applied FFmpeg to apply effects on videos. Details about how to do that can be seen on this wiki page
  • Some emulators have problems during video playback so try on real device when that happens e.g: Android Lollipop emulators don't show video.

How to use it

  • Add the following code to your project's build.gradle file
  repositories {
        jcenter()
    }
  • Add the following gradle path to your app/build.gradle file
dependencies {
//	Gradle path for VidEffects
   	implementation "com.sherazkhilji.videffects:videffects:1.1.0"
}
  • Then you need to add VideoSurfaceView either using java code or as xml in your layout file.
<com.sherazkhilji.videffect.view.VideoSurfaceView
       android:id="@+id/mVideoSurfaceView"
       android:layout_width="match_parent"
       android:layout_height="match_parent" />
  • Then you need to reference the VideoSurfaceView and call its init() method in your Activity or Fragment onCreate() supplying it with a MediaPlayer instance and a Video Effect. Also you would need to call VideoSurfaceView onResume() in your Activity or Fragment onResume() so that your video is rendered properly.
	@Override
   protected void onCreate(Bundle savedInstanceState) {
   	super.onCreate(savedInstanceState);

   	mResources = getResources();
   	mMediaPlayer = new MediaPlayer();

   	try {
   		// Load video file from SD Card
   		// File dir = Environment
   		// .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
   		// File file = new File(dir,
   		// "sample.mp4");
   		// mMediaPlayer.setDataSource(file.getAbsolutePath());
   		// -----------------------------------------------------------------------
   		// Load video file from Assets directory
   		AssetFileDescriptor afd = getAssets().openFd("sample.mp4");
   		mMediaPlayer.setDataSource(afd.getFileDescriptor(),
   				afd.getStartOffset(), afd.getLength());
   	} catch (Exception e) {
   		Log.e(TAG, e.getMessage(), e);
   	}
   	// Initialize VideoSurfaceView using code
   	// mVideoView = new VideoSurfaceView(this);
   	// setContentView(mVideoView);
   	// or
   
   	mVideoView = (VideoSurfaceView) findViewById(R.id.mVideoSurfaceView);
   	mVideoView.init(mMediaPlayer,
   			new DuotoneEffect(Color.YELLOW, Color.RED));
           setContentView(R.layout.activity_sampleplayer);
   }

   @Override
   protected void onResume() {
   	super.onResume();
   	mVideoView.onResume();
   }
  • Incase of any confusion, check the file SamplePlayerActivity for a complete example on how to apply different Effects on your videos.
  • For Advance implementation and saving Filters, check the file VideoActivity

See it in working

Video screenshot without any Effect

Video screenshot without any Effect

Video screenshot with Black and White Effect

Video screenshot with Black and White Effect

Video screenshot with Invert Colors Effect

Video screenshot with Invert Colors Effect

Special Thanks to

Development

Want to contribute or add some new Effects? Great! Fork it and send me a pull request or contact me on the email below, if you want to become a permanant contributor.

Developed by

License

Copyright 2020 Sheraz Ahmed Khilji

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.
Comments
  • CRASH | When trying to Save Video.

    CRASH | When trying to Save Video.

    Hello Developer!

    I appreciate your all Hard Work!!

    I am trying to save the video. I have written the Code from WIKI.

    I am getting below errors -

    E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: mappractise.tv.com.demovideofilter, PID: 21407 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.avutil at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:324) at org.bytedeco.javacpp.Loader.load(Loader.java:413) at org.bytedeco.javacpp.Loader.load(Loader.java:381) at org.bytedeco.javacpp.avformat$AVFormatContext.<clinit>(avformat.java:2597) at org.bytedeco.javacv.FFmpegFrameGrabber.startUnsafe(FFmpegFrameGrabber.java:386) at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:380) at mappractise.tv.com.demovideofilter.VideoProcessing.doInBackground(VideoProcessing.java:49) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818) 

    opened by shoebhoney 6
  • Save Video with effects : plan

    Save Video with effects : plan

    Hi,

    As you mentioned in ReadMe that In the future, you are aiming to apply permanent effect to videos. So, i wanted to ask about the approach you would be following to implement this behaviour.

    opened by Zer0bee 3
  • getShader null object reference

    getShader null object reference

    Attempt to invoke interface method 'java.lang.String es.veera.video2gif.filter.ShaderInterface.getShader(android.opengl.GLSurfaceView)' on a null object reference

    opened by ashishvirani29 3
  • VideoSurfaceView can't auto size base video's height and width

    VideoSurfaceView can't auto size base video's height and width

    Hi,I find the VideoSurfaceView when playing video ,the content will fill of the view, But VideoView can base on video' height and width to scale the content ,no daaw out of the content. My english not well,do you clear?

    opened by moonshoter 2
  • How to save video?

    How to save video?

    Hey Developer !

    Great Work Done!!

    I have successfully implemented the video effects, now i just need to save the video after applied effects on it.

    Please let me know or suggest me what i need to do.

    Looking forward to hear from you.

    Thanks :+1:

    Kind regards Shoeb Siddique

    opened by shoebhoney 1
  • Crash when returning to the app

    Crash when returning to the app

    Hi,

    First of all, thank you for this library. Is such a helpful one. I started playing around with it and I get the following exception when returning to the app. Do you any idea why this is happening? Thank you!

    FATAL EXCEPTION: GLThread 19220 Process: com.famous.app, PID: 9602 Theme: themes:{default=overlay:com.cyngn.hexo, iconPack:com.cyngn.hexo, fontPkg:com.cyngn.hexo, com.android.systemui=overlay:com.cyngn.hexo, com.android.systemui.navbar=overlay:com.cyngn.hexo} java.lang.IllegalStateException at android.media.MediaPlayer._setVideoSurface(Native Method) at android.media.MediaPlayer.setSurface(MediaPlayer.java:753) at com.sherazkhilji.videffect.view.VideoSurfaceView$VideoRender.onSurfaceCreated(VideoSurfaceView.java:257) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1503) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

    opened by cristin 1
  • How to apply VidEffects to Wallpaper

    How to apply VidEffects to Wallpaper

    Hi, how can apply VidEffects to a wallpaper ? I´m asking because in your notes, is need a activity or fragment . It´s possible to add and use the library to a Wallpaper ?

    Thank you

    opened by spe4all 1
  • Release 1.1.0

    Release 1.1.0

    Description:

    • Added ability to Save Video (Only works for Filters at the moment)
    • Added VideoActivity which is responsible for dynamically applying Filters and then saving them to storage.
    • Fixed crashes
    • Updated gradle dependencies

    Release contain the following PRs:

    • #30
    Version 1.1.0 
    opened by krazykira 0
  • how to save video without AssetFileDescriptor

    how to save video without AssetFileDescriptor

    HI I have issue i am capturing video from camera and want to apply filters on it But here i found filters only on assets in android studio Kindly suggest me code for this I do not want to apply filters on assets

    opened by junaidandroidcp 3
  • How to create Color channel mixers for different  filters ?

    How to create Color channel mixers for different filters ?

    Color Channel Mixer (Info.) https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer

    I am trying to creating video filters using FFMpeg and OpenCV just like Instagram Video filters. So if I want to create Sepia Effect Then I have to use color channel mixer for that with RGBA values ex. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131 (This code for Sepia Effect) Now I want to create more effects like Instagram. So need different color channel mixers for that How to create them?

    Ref. -- https://github.com/krazykira/VidEffects/wiki/Permanent-video-effects

    I got only 2 filters

    1. Sepia colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131

    2. Grayscale colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3

    I need more filters.

    private void initVideoRecorder(String path) { 
    try { 
    filter = new F FmpegFrameFilter("colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131", VIDEO_GRABBER.getImageWidth(), VIDEO_GRABBER.getImageHeight()); 
    videoRecorder = FFmpegFrameRecorder.createDefault(path, VIDEO_GRABBER.getImageWidth(), VIDEO_GRABBER.getImageHeight()); videoRecorder.start(); 
    } 
    catch (FrameRecorder.Exception e) { 
    e.printStackTrace(); 
    }
     }
    
    opened by iharshb 0
  • glDrawArrays: glError 1282

    glDrawArrays: glError 1282

    java.lang.RuntimeException: glDrawArrays: glError 1282 at com.sherazkhilji.videffects.view.VideoSurfaceView$VideoRender.checkGlError(VideoSurfaceView.java:355) at com.sherazkhilji.videffects.view.VideoSurfaceView$VideoRender.onDrawFrame(VideoSurfaceView.java:199) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1562) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1262

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); checkGlError("glDrawArrays");

    I have integrated this sdk. I am getting above error while playing video after applying filter. Device Samsung galaxy edge S6+

    opened by mohitauappface 0
  • After Video processing video is faster. how to fix that ?

    After Video processing video is faster. how to fix that ?

    After Applying shader on video and Processing video by FFmpeg with your sample code which in Wiki page .

    Issue : FFmpeg Recording Issue video is faster after video processing with channelmixer .

    opened by iharshb 3
  • Saving effected video in sdcard . Effect issue channel mixer!

    Saving effected video in sdcard . Effect issue channel mixer!

    Hello,

    As you mention here for permanent video effecting and saving video in sdcard.
    https://github.com/krazykira/VidEffects/wiki/Permanent-video-effects

    When i am applying diffrent effects how you change that channelmixer for diffrent effects ?

    As you mention in demo colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131 i want different Frame filters for diffrent effects which you mention in your library

    BrightnessEffect, ContrastEffect, AutoFixEffect, BlackAndWhiteEffect, CrossProcessEffect

    private void initVideoRecorder(String path) { try { filter = new F FmpegFrameFilter("colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131", VIDEO_GRABBER.getImageWidth(), VIDEO_GRABBER.getImageHeight()); videoRecorder = FFmpegFrameRecorder.createDefault(path, VIDEO_GRABBER.getImageWidth(), VIDEO_GRABBER.getImageHeight()); videoRecorder.start(); } catch (FrameRecorder.Exception e) { e.printStackTrace(); } }

    opened by iharshb 0
Releases(1.1.1)
  • 1.1.1(Dec 29, 2021)

  • 1.1.0(Apr 8, 2020)

    • Added Advance Sample app to apply Effects and Filters during runtime.
    • Added ability in library to save video once a Filter (Not Effect) is applied.
    Source code(tar.gz)
    Source code(zip)
Owner
Sheraz Ahmad Khilji
Technology geek by mind, OpenSource enthusiast by nature and Android developer by profession. (ノ・ェ・)ノ
Sheraz Ahmad Khilji
Apply custom effects on view backgrounds

View Filters At the beginning the only purpose was to blur all layers below. Now you can do more : Blur background views easily Create custom filters

Mad Mirrajabi 180 Nov 25, 2022
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

Levi Bostian 56 Oct 3, 2022
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

Levi Bostian 56 Oct 3, 2022
A Jetpack Compose-based app to exhibit all the beautiful GLSL Fragment shaders I have ever written, where you can set them as Live Wallpaper.

?? Shader Showcase Shader Showcase is a minimal Android app made with Jetpack Compose, to showcase all the beautiful OpenGL* based Fragment shaders I

Piyush Pradeepkumar 198 Dec 28, 2022
Runtime Mobile Security (RMS) 📱🔥 - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime

Runtime Mobile Security (RMS) ?? ?? by @mobilesecurity_ Runtime Mobile Security (RMS), powered by FRIDA, is a powerful web interface that helps you to

Mobile Security 2k Dec 20, 2022
This is a very simple library for Android that allows you to stick an header to a scrollable view and easily apply animation to it

StikkyHeader This is a very simple library for Android that allows you to stick an header to a ListView and easily apply animation to it Usage To use

Carlo Marinangeli 847 Dec 30, 2022
How to apply meaningful and delightful motion in a sample Android app

Applying meaningful motion on Android How to apply meaningful and delightful motion in a sample Android app Read the complete post at https://medium.c

André Mion 166 Nov 12, 2022
[] Apply background tinting to the Android system UI when using KitKat translucent modes

Android System Bar Tint Apply background tinting to the Android system UI when using KitKat translucent modes. Android 4.4 (KitKat) introduced translu

Jeff Gilfelt 5.4k Dec 9, 2022
How to apply meaningful and delightful motion in a sample Android app

Applying meaningful motion on Android How to apply meaningful and delightful motion in a sample Android app Read the complete post at https://medium.c

André Mion 167 Dec 19, 2022
How to apply meaningful and delightful motion in a sample Android app

Applying meaningful motion on Android How to apply meaningful and delightful motion in a sample Android app Read the complete post at https://medium.c

André Mion 167 Dec 19, 2022
MVVM Redux is a lightweight lib to help you apply the redux concepts in your project based in MVVM.

MVVM Redux is a lightweight lib to help you apply the redux concepts in your project based in MVVM.

Gabriel Brasileiro 36 Oct 16, 2022
load-the-image Apply to compose-jb(desktop), Used to load network and local pictures.

load-the-image load-the-image Apply to compose-jb(desktop), Used to load network and local pictures. ?? Under construction It may change incompatibly

lt_taozi 13 Dec 29, 2022
This application uses Google Play Services Vision library to scan barcodes. It uses Google's on device ML kit to scan for barcodes.

Barcode-Scanner This application showcases use of Google Play Services Vision library It uses Google's on device machine learning kit to scan for barc

Soumik 2 Apr 28, 2022
Primitive OpenGL (ES) based graphics library and engine for Android development.

Parrot Primitive OpenGL (ES) based graphics library and engine for Android development. Parrot makes Android core graphics simpler, giving you the fea

null 1 Dec 30, 2021
The Okila server project uses the Spring boot framework and uses the Kotlin language

Okila-Server The Okila server project uses the Spring boot framework and uses the Kotlin language Format Response //The response successfully format

Nankai 1 Oct 25, 2021
Android library to auto-play/pause videos from url in recyclerview.

AutoplayVideos Show some ❤️ and star the repo to support the project This library is created with the purpose to implement recyclerview with videos ea

Krupen Ghetiya 989 Nov 17, 2022
Android OpenGL ES 2.0/3.0 Engine

Build Status Master Branch Status Develop Branch Status News 06/23/2017 Bombshell 1.1.970 has been released. It fixes behavior of Objects of zero size

null 2.2k Jan 9, 2023
Android filters based on OpenGL (idea from GPUImage for iOS)

GPUImage for Android Idea from: iOS GPUImage framework Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are e

CATS Open Source Softwares 8.6k Dec 28, 2022
Free Android 2D OpenGL Game Engine

AndEngine Donations While developing AndEngine was a lot of fun, it also also consumed many(!) months of my life. It actually continues to cost me a s

Nicolas Gramlich 3.2k Jan 5, 2023
Android filters based on OpenGL (idea from GPUImage for iOS)

GPUImage for Android Idea from: iOS GPUImage framework Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are e

CATS Open Source Softwares 8.6k Jan 8, 2023