masayukisuda / exoplayerfilter Goto Github PK
View Code? Open in Web Editor NEWThis library uses OpenGL Shaders to apply effects on ExoPlayer video at Runtime
This library uses OpenGL Shaders to apply effects on ExoPlayer video at Runtime
Hello, Everyone! I was wondering if there is a way to save the video into device storage after applying filters to it?
Hi I just tried to do multiple instances of the playerview in a viewpager but it didn't work, and I was wondering why do you have any idea?
I need to save the video after applying the filter, is there a way i can do it?
Thank you for this library @MasayukiSuda. I was wondering if is possible to add a TextureView of this approach to have regular View animations like scaling, fading, etc.
Also: Is this library also allows me to use "resize_mode" like SimpleExoPlayerView? "fixed_height" is a scale that I can't move from it. Currently I can't have the video full screen with that resize mode crop.
Thanks in advance!
I would like to play a video that uses the color green to indicate transparency.
I already have a shader that is working with another video playback library, but I would like to get the power of ExoPlayerFilter in the app instead.
precision mediump float;
varying vec2 vTextureCoord;
uniform lowp sampler2D sTexture;
void main() {
lowp vec4 color = texture2D(sTexture, vTextureCoord);
vec3 green = vec3(0.173, 0.435, 0.078);
if (color.r <= green.r && color.b <= green.b) {
// dont render anything (transparent) // this doesnt work
// gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); // also shows black instead of transparent
} else {
color.r = color.r * 1.6;
color.b = color.b * 1.6;
if (color.r >= 1.0 || color.b >= 1.0) {
color.g = color.g * 1.6;
} else {
color.g = color.g * 1.2;
}
float a = distance(green, vec3(color.r, color.g, color.b));
gl_FragColor = vec4(color.r, color.g, color.b, a);
}
}
// this did not help
ePlayerView.holder.setFormat(PixelFormat.TRANSPARENT)
When I use this shader with DEFAULT_VERTEX_SHADER it shows black in place of the green. How can this be transparent instead?
Great library! Congrats.
I can see you have thought about different options for fitting the surface inside the parent (playerScaleType), but probably haven't gotten round to finishing it. So if you put a portrait video into the library it fills the width and therefore crops the top and bottom of the video.
I figure this must be a solved problem somewhere. Would the code from VideoView not do what you (I) need?
I can just override onMeasure for now, so it isn't a problem.
Hello,
I update Exoplayer to 2.7.0 but have problem in your library about Listener then I revert Exoplayer version 2.6.1
03-05 18:42:31.721 14389-14389/com.videoplayer E/AndroidRuntime: FATAL EXCEPTION: main Process: com.videoplayer, PID: 14389 java.lang.NoSuchMethodError: No virtual method addVideoListener(Lcom/google/android/exoplayer2/SimpleExoPlayer$VideoListener;)V in class Lcom/google/android/exoplayer2/SimpleExoPlayer; or its super classes (declaration of 'com.google.android.exoplayer2.SimpleExoPlayer' appears in /data/app/com.videoplayer-2/split_lib_dependencies_apk.apk) at com.daasuu.epf.EPlayerView.setSimpleExoPlayer(EPlayerView.java:46) at com.videoplayer.editvideo.FilterVideoFragment.setUpGlPlayerView(FilterVideoFragment.kt:84) at com.videoplayer.editvideo.FilterVideoFragment.onResume(FilterVideoFragment.kt:97) at android.support.v4.app.Fragment.performResume(Fragment.java:2387) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1467) at android.support.v4.app.FragmentManagerImpl.performPendingDeferredStart(FragmentManager.java:1230) at android.support.v4.app.FragmentManagerImpl.startPendingDeferredFragments(FragmentManager.java:1857) at android.support.v4.app.FragmentManagerImpl.doPendingDeferredStart(FragmentManager.java:2704) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2220) at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:649) at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145) at android.support.v4.view.ViewPager.populate(ViewPager.java:1238) at android.support.v4.view.ViewPager.populate(ViewPager.java:1086) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1616) at android.view.View.measure(View.java:18870) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464) at android.view.View.measure(View.java:18870) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464) at android.view.View.measure(View.java:18870) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.view.View.measure(View.java:18870) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464) at android.view.View.measure(View.java:18870) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141) at android.view.View.measure(View.java:18870) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435) at android.widget.LinearLayout.measureVertical(LinearLayout.java:721) at android.widget.LinearLayout.onMeasure(LinearLayout.java:612) at android.view.View.measure(View.java:18870) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.view.View.measure(View.java:18870) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435) at android.widget.LinearLayout.measureVertical(LinearLayout.java:721) at android.widget.LinearLayout.onMeasure(LinearLayout.java:612) at android.view.View.measure(View.java:18870) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:3076) at android.view.View.measure(View.java:18870) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2392) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1416) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1661) at android.view.ViewRootImpl.doTra
Hello,
When i launch the sample from branch master I get the following error :
W/SimpleExoPlayer: Player is accessed on the wrong thread. See https://exoplayer.dev/issues/player-accessed-on-wrong-thread
java.lang.IllegalStateException
at com.google.android.exoplayer2.SimpleExoPlayer.verifyApplicationThread(SimpleExoPlayer.java:1242)
at com.google.android.exoplayer2.SimpleExoPlayer.setVideoSurface(SimpleExoPlayer.java:321)
at com.daasuu.epf.EPlayerRenderer.onSurfaceCreated(EPlayerRenderer.java:103)
at com.daasuu.epf.EFrameBufferObjectRenderer.onSurfaceCreated(EFrameBufferObjectRenderer.java:40)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)
Same issue when i try to use the lib in my project.
Any idea ? Thanks in advance
Unable to open this project in com.android.tools.build:gradle:2.2.0. Below error is thrown.
Error:Failed to resolve: com.android.support:support-annotations:27.0.0
Install Repository and sync project
Open File
Show in Project Structure dialog
Error:(24, 13) Failed to resolve: com.android.support:appcompat-v7:26.1.0
Install Repository and sync project
Show in File
Show in Project Structure dialog
How can i save video after apply any filter?
1.Does filter support android mediaplayer?
2.How do I save the filter to local MP4?
thanks!
Hi, its really cool library to play with.
However, I am trying to set full screen MovieWrapperView, but I am not able to do so.
I tried setting height width in XML to match parent and tried to set it through java file too, but not getting perfect result. Can you please guide me.
Thanks in advance.
When trying to add your library to a project using implementation 'com.github.MasayukiSuda:ExoPlayerFilter:v0.2.4'
I get an error
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.github.MasayukiSuda:ExoPlayerFilter:v0.2.4.
Full text - https://hasteb.in/evuqaruw.sql
Maybe you know the solution?
Is there a possibility to retrieve the current frame from EPlayerView?
我想实现一个类似GPUImageColorMatrixFilter 传矩阵的颜色怎么实现呢
exoPlayer!!.repeatMode=Player.REPEAT_MODE_ALL
exoPlayer!!.playWhenReady=true
playerView = EPlayerView(this)
playerView.setSimpleExoPlayer(exoPlayer)
playerView.setLayoutParams(RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
(findViewById<RelativeLayout>(R.id.player_view)).addView(playerView)
playerView.onResume()
playerView.setGlFilter(GlSepiaFilter())
if(!started)playNext()
}
-------------------------------------------------------------------------------------------------------------------------------------
2019-09-27 04:41:44.053 29865-29898/me.xx.xxxx W/SimpleExoPlayer: Player is accessed on the wrong thread. See https://exoplayer.dev/issues/player-accessed-on-wrong-thread
java.lang.IllegalStateException
at com.google.android.exoplayer2.SimpleExoPlayer.verifyApplicationThread(SimpleExoPlayer.java:1231)
at com.google.android.exoplayer2.SimpleExoPlayer.setVideoSurface(SimpleExoPlayer.java:321)
at com.daasuu.epf.EPlayerRenderer.onSurfaceCreated(EPlayerRenderer.java:103)
at com.daasuu.epf.EFrameBufferObjectRenderer.onSurfaceCreated(EFrameBufferObjectRenderer.java:40)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1539)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)
2019-09-27 04:41:44.055 29865-29898/me.xx.xxxx E/[EGL-ERROR]: __egl_platform_cancel_buffers:644: surface->num_buffers(4) ```
-------------------------------------------------------------------------------------------------------------------------------------
ExoPlayer Core Version 2.10.2 & 2.10.4
Android Version: Oreo GO
Tried using layout instead of doing it programmatically but is the same.
------------------------------------------------------------------------------------------------------------------------------------
Tried sample app, and is working, but in my app it continues to crash.
hi, sorry I know this isnt an issue but didnt know how to ask otherwise.
Is it possible once you apply a filter to save the video as a copy with the chosen filter?
Hi,
How to support 360-degree VR Videos render?
Thanks.
Hi @MasayukiSuda ,
I have attached a video which is getting stuck when i am previewing with ExoPlayerFilter.
Using ExoPlayer and SimpleExoPlayerView, preview rendering works alright.
Can u please help me out with this.
Attaching both original_video and stuky_preview_video ,
Thanks
There is a video with rotation 90, when i play the video, not shown in the right direction, how can i fix it?
I've used your exoplayerfilter and it is working fine. What I'm looking for is a vintage filter, do we have vintage filter? If not then please give some suggestion for some way to inculcate in this filter. Thanks
I want to rotate the video but i couldn't find any method, I have tried rotate the parent layout but it wasn't successful
I wan to remove filter with the press of a button and come back to normal. I've searched on this library I couldn't found any thing for removing the filter or coming back to normal.
Please let me know if there is anything from which I can remove the filter like setting the filters. Thanks.
The work is almost done, now I've to save the filtered video in the local storage. I'm searching for a way out to do that. Do we have something to save the video with the applied filter. As when we apply filter to some video. How to do we get the value of the changed video in order to save it in the specified path.
Thanks
During rotaion EPlayerView
is gone .
anybody have solution for this?
I used
Matrix.rotateM(MVPMatrix, 0, 90, 0, 0, 1);
but video is strached. Please help me
I refer #8 but no one answered here
Assume that I have a 50 seconds video. I want to apply filter only from 20 to 30 second.
How to do that ? Thank you!
Anyone. know how to save filter Video in Exoplayer. give any library for save it.
If I use this library and use SimpleExoPlayerView for simple use for other work then:
java.lang.NoSuchMethodError: No interface method addListener(Lcom/google/android/exoplayer2/ExoPlayer$EventListener;)V in class Lcom/google/android/exoplayer2/ExoPlayer; or its super classes (declaration of 'com.google.android.exoplayer2.ExoPlayer' appears in /data/app/com.emergingcoders.socio-1/base.apk)
So, I currently forget to use this library!
How to apply multiple filters?
I try to add video filter with video view at my fragment in my application which add video filter before to save this follow example in README.md with kotlin
private fun setUpSimpleExoPlayer() {
val bandwidthMeter = DefaultBandwidthMeter()
val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory(bandwidthMeter)
val trackSelector = DefaultTrackSelector(videoTrackSelectionFactory)
val defaultBandwidthMeter = DefaultBandwidthMeter()
val dataSourceFactory = DefaultDataSourceFactory(context, Util.getUserAgent(context, "Video-editor"), defaultBandwidthMeter)
val extractorsFactory = DefaultExtractorsFactory()
val videoSource = ExtractorMediaSource(Uri.parse(getString(R.string.sample_media_mp4_portrait)), dataSourceFactory, extractorsFactory, null, null)
player = ExoPlayerFactory.newSimpleInstance(context, trackSelector)
player.prepare(videoSource)
player.playWhenReady = true
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.daasuu.epf.EPlayerView
android:id="@+id/layoutMovieWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
and have error at this which I cannot to fix this, what should I do about this?
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.exoplayer2.SimpleExoPlayer.setVideoSurface(android.view.Surface)' on a null object reference
at com.daasuu.epf.EPlayerRenderer.onSurfaceCreated(EPlayerRenderer.java:103)
at com.daasuu.epf.EFrameBufferObjectRenderer.onSurfaceCreated(EFrameBufferObjectRenderer.java:40)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1539)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1278)
GLES20.glTexParameteri(target, GL_TEXTURE_MAG_FILTER, mag);
GLES20.glTexParameteri(target, GL_TEXTURE_MIN_FILTER, min);
not use glTexParameterf
亲爱的作者大大 支持加速播放吗? @MasayukiSuda
I am having trouble rendering the video in a way that it fits the layout.
((FrameLayout) findViewById(R.id.videoView3)).addView(ePlayerView);
I have defined a frame layout, and it takes a particular width and height, however when I add this player in this view, it does not fit, it only stretches till the video height.
I want it to scale to the height and width of the layout.
About opengl some device hava an Exception:createContext failed: EGL_BAD_CONFIG,
like VIVO Android 8.1
Please help me how to solve it.Thank you very much.
It would be great if the library didn't include ExoPlayer itself, which would make it possible to update ExoPlayer whenever new updates come in. Right now there are bug fixes in the latest ExoPlayer release which I can't use with this library.
hey,
I'd like to use your lib along with the latest exoplayer version 2.6.1
however in the lib is used version 2.6.0, which makes build fail due to different versions.
It is possible to change lib version to the latest one?
p.s. I've tried it locally, works ok, no additional efforts required.
device: Huawei V8
android version: 8.0
gl info:
vendor:Arm version:OpenGL ES 3.2
renderer:Mali-T880
the demo will crash when i select GlMonochromeFilter or GlVignetteFilter .
after a try , i found out change the following code will fix crash.
GLES20.glUniform3fv(getHandle("xxxxx"), 0, vignetteColor, 0);
---- will crash
to
GLES20.glUniform3fv(getHandle("xxxxx"), 1, vignetteColor, 0);
------ this works for me
I'm not good at opengl es, so I'm not sure about this .
any way, could you please check this ?
thanks for this gorgeous project!
I saw you code rendering rate depend on video decode rate.
and then try to send request to GLThread call drawframe function.
however the GLsurfaceView render mode is not dirty mode, that means remaining continue mode.
in my view, should set dirty mode better way.
I have been doing this change either by using scaleX = -1 in xml or using texture view.
Using scaleX gives me black screen and I can't use texture view with this player.
Can you add a method to flip the video? @MasayukiSuda
I have a problem here, need to resize the EPlayerView size to fit in specific size the video leaving left and right part transparent if video is vertical. As for now in your demo video is horizontal and if I put a vertical video it will be put across the whole screen. Is there a way to resize the EPlayerView according to video size?
GLES20.glBindTexture(GL_TEXTURE_2D, 0); should be GLES20.glBindTexture(texTarget, 0);
In Draw function.
How can i save video on sdcard after effect given on video.
Is there any example on how to to adjust the parameter of one of your filters, say "brightness" using slider?
Can add a transparent filter?
Implementation of others
https://github.com/lvpengwei/ExoPlayerFilter
lvpengwei@134e5dc
I was wondering if there is any code example or source that would guide me on how to use media codec to save the video after applying a filter to it?
I found the following error log when running in the emulator.
Pixel 2 API 29 - Android 9.+
I think this is due to some restriction introduced after android 8. See
https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted
2019-07-01 16:48:33.175 4984-5723/com.daasuu.exoplayerfilter E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://www.html5videoplayer.net/videos/toystory.mp4
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:194)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:147)
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:844)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:320)
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)
Caused by: java.io.IOException: Cleartext HTTP traffic to www.html5videoplayer.net not permitted
at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:124)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:462)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:429)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:350)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:192)
Should you release the Surface
you create in EPlayerRenderer when you finish using the EPlayerView
? Otherwise you are leaking the Surface
. You can see this by enabling StrictMode
and creating and destroying an Activity
with an EPlayerView
.
I also notice that you have a release
method in ESurfaceTexture that I couldn't see being used. Should that also be called?
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.