Open peterstickermaker opened 4 months ago
Calling setVideoEffects
to update the effects sounds like the right way to do this (though it may be inefficient if it needs to tear everything down and set up the pipeline again).
@claincly Please could you take a look?
Hi @andrewlewis I have a list of effects that users can choose from, allowing them to see a video preview. However, if I reset the player and then prepare it again every time a new effect is applied, it seems awkward. I would like to keep the player playing while the user applies different effects, similar to many video apps.
Hey @peterstickermaker, the intended usage is just call .setVideoEffects()
when you want to change the set of effects, and you don't need to re-initialize the player. To be more concrete, you can do
ExoPlayer player = new ExoPlayer.Builder(context).build();
player.setMediaItem(...);
player.setVideoEffects(effectList1);
player.prepare();
player.play();
// Change effects
player.setVideoEffects(effectList2);
player.setVideoEffects(effectList3);
player.setVideoEffects(effectList4);
...
There's a caveat here though - the effect change won't be frame specific, i.e. there is no guarantee that the new set of effects will be applied on the immediate next frame after the user-touch-event.
Thank you @claincly When I change the effects, sometimes it takes a long time for the effects to be applied, and sometimes the video player gets stuck.
Thank you @claincly When I change the effects, sometimes it takes a long time for the effects to be applied, and sometimes the video player gets stuck.
I have an application that allows users to select different filters/effects to be applied to a video preview before exporting. I know that we can call
exoPlayer.setVideoEffects()
to set the list of effects, but the method has noted that 'This method should be called before calling [prepare](https://developer.android.com/reference/kotlin/androidx/media3/common/Player#prepare()).' I tried to callexoPlayer.setVideoEffects
to change the video effect dynamically, but the video preview sometimes got stuck.The third-party library https://github.com/MasayukiSuda/GPUVideo-android that allows integration with ExoPlayer works very nicely, but I am looking for the official approach from Media3 (if any). Do you have any solution for this?