Git Product home page Git Product logo

videffects's Introduction

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, (Available on Jcenter)
1.1.1 - Updated Dependencies & Published the videffects to MavenCentral. All future versions from now onwards will be distributed via MavenCentral.

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 {
        mavenCentral()
    }
  • Add the following gradle path to your app/build.gradle file
dependencies {
//	Gradle path for VidEffects
   	implementation "com.github.krazykira:videffects:1.1.1"
}
  • 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 2022 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.

videffects's People

Contributors

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

videffects's Issues

apply Effects as Filters?

how to apply effects because i found only 3 filters in this code. all others are effect tell me how to apply and save video with these effect?

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)

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 👍

Kind regards
Shoeb Siddique

want to add blur filter.

Hey brother, i want to add a blur filter to the video, but i am trying hard and cannot get the breakthrough, can you help me over that.

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.

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

Save effected video

Hi, i can't see any function about save effected video. Is there any way to do this? thanks

apply filters to a single frame in code

So this repo applies effect to a media player playing a video. In my app, I have access to frames of the video. Is there a way to use your library to apply filters to a frame (media.Image type) not the whole video?

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(); } }

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

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+

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

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) 

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(); 
}
 }

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.