Is possible to change video effect dynamically ?
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.' I tried to call exoPlayer.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?
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.
Related to https://github.com/androidx/media/issues/1535
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. @peterstickermaker May I ask if this issue has been resolved?
Hmm do you still see the video player being stuck? If possible could you open a separate bug and attach your set up so we could reproduce?
Hello, did anyone find a fix for this issue, by chance? It still gets stuck if you do something like this:
ExoPlayer player = new ExoPlayer.Builder(context).build();
player.setMediaItem(...);
player.setVideoEffects(effectList1);
player.prepare();
player.play();
// Change effects
player.setVideoEffects(effectList2);
player.setVideoEffects(effectList3);
Hi @valentinbrad-wolfpack , what media3 version are you testing with and what kind of effects?
Same problem. I face. The effect doesn't shows up in the preview and we need to reinitialize the player to see to see the applied preview.
Although if we use:
ExoPlayer player = new ExoPlayer.Builder(context).build();
player.setMediaItem(...);
player.setVideoEffects(effectList1);
player.prepare();
player.play();
// Change effects
player.setVideoEffects(effectList2);
player.setVideoEffects(effectList3);
for now as mentioned. We see this issue #2505
@ranjitsingha Let's continue the discussion in #2505.