-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shaders applied as GLEffects in transformer have different results than applying them directly to a GLSurfaceView #1080
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
Summary: I'd recommend you to simply use setVideoEffects. More detailed answer below
It seems you're using 2 different paths. (1) ExoPlayer's VideoProcessingGLSurfaceView is a very thin wrapper with ~no color transformations (operating on input colors by default), whereas (2) Transformer, or ExoPlayer.setVideoEffects does have some color transformations (operating in linear colors by default). The "something special" is these color transformations, in our glsl shaders. If you're only doing SDR, you can apply the SMPTE 170m transfers (EOTF / OETF) to replicate this, but this may differ based on input/output colors if you have HDR input, so I'd recommend you to simply use setVideoEffects if possible to have consistent color transformations applied, especially as you're using this in Transformer too.
You should be able to call setVideoEffects while the video is playing, to update the effects. We hope to improve this implementation in the future though as it does a lot of reconfiguration at the moment under the hood, but I believe this should already work. We unfortunately don't properly handle updating the displayed frame when setVideoEffects is called while a video is paused, but we do plan to support this in the future. |
Thanks for the quick response! This is exactly the problem I am having. Using setVideoEffects() directly on the exoPlayer the results are the same. As you say, the "default" shader I am applying to the GLSurfaceView does not apply any color transformation before applying other shaders, but the "DefaultShaderProgram" from media3 applies color transformations and then the rest of the shaders. Using setVideoEffects() is the solution. However, I have a couple of issues with it:
I will play around to see if I can make setVideoEffects() work for me or if I go the "color transformation in my implementation" route. |
Thanks, this makes sense now. Yeah I suspect that the right path here for our library would be to fix the issues you mentioned with Could you please consider filing new issues for your second and third bullet points? Also, some info before you file in case it helps...
I wonder if the issue is that setVideoEffects is called whenever the slider moves, since it does incur some background processing, and maybe a debounce (calling setVideoEffects a max of once per 10ms or 100ms) might help. We currently flush all frames and re-create all shaders when it's called, but we hope to improve this in the future (ex. to re-create only updated shaders).
This sounds like you're hitting a hang (deadlock??) somehow. Please file a bug for this since this definitely shouldn't happen. |
Closed per the prior comment, but please file new bugs for the other issues mentioned in the bullet points (or reopen if you think there's something else we should have covered) |
For updating your effects responsively with a slider - I've tried the following and it's working well (the effect updates smoothly on slider value change), but it has some caveats that I'll list towards the bottom
Caveats
|
@claincly Did you have a prototype for allowing triggering re-rendering (and showing the resulting frame as quickly as possible)? I remember we talked about that a long time ago. Maybe we should mark this as an enhancement request to implement that. |
Nice, I'll play around with this info. Regarding the previous info about the color changes, I have been looking into the source code of the DefaultShaderProgram and realized that for SDR content I can disable "enableColorTransfers".
This way the color transfers are disabled and the shaders are applied the same way I am applying them in the GLSurfaceView. This is also useful to apply the same effects to other stuff that is not a video, as I am using the player and transformer to generate videos with images as sources, and as far as I know images are not being affected by setVideoEffects() on the exoplayer for now (images are not even shown). I am using an ImageOutput and applying the effects to them on their own. Thanks for the help! |
Update: The last comment "solution" does not work if you want to apply OverlayEffects to the resulting video. For some reason, the OverlayEffect always converts the bitmaps to optical color and expects the video to be this way when applying the shader. This basically makes the colors of the overlay wrong when color transfers are disabled in the transformer, because it only affects the video and not the overlayEffect. |
I am applying shaders to a GLSurfaceView where an Exoplayer is playing a video (based on your VideoProcessingGLSurfaceView demo), and then I am exporting the video with Transformer applying the same shaders to the MediaItems (as GLEffects).
The effects are notably different in the GLSurfaceView and in the Transformer result, it seems the Transformer has more "intensity" in the effects.
As an example, I have a simple brightness shader as a GLEffect:
fragment_shader_brightness.glsl
For an intensity of 0,2 to a black background, the results are the following:
The shader applied in the Transformer is clearly more "white". Getting closer to 100 intensity the results are more similar, however in lower intensities the shaders differ a lot. This happens for every shader I am using (in some is more noticeable than others).
I know I could apply the effects to the Exoplayer through setVideoEffects(), but it does not work well when changing the effect intensity "in real time" while the video is playing, and I need it to be applied to pictures as well. (An interactive preview of the effect applied to the Transformer result)
My question is, is there something special done to the textures when applying the effects? How can I replicate the same shader result applying it to a GLSurfaceView.
The text was updated successfully, but these errors were encountered: