Black Bounds when setVideoEffects
Version
Media3 main branch
More version details
media3 version is 1.8.0-alpha01
Devices that reproduce the issue
All
Devices that do not reproduce the issue
None
Reproducible in the demo app?
Yes
Reproduction steps
When i set player.setVideoEffects() to display the applied effects on the player the video expands to the parent view. (Only the black part)
But when i remove the player.setVideoEffects or set it to player.setVideoEffects(null) i get no problem.
Expected result
Expected to remove the black part/the black gaps. Must not expand to the parent view.
Actual result
remove the black part/the black gaps. Must not expand to the parent view.
Media
None
Bug Report
- [ ] You will email the zip file produced by
adb bugreportto [email protected] after filing this issue.
I guess you rely on the Player.Listener.onVideoSizeChanged() callback to layout your view (the white bounds)? In short with video effects, that callback is not invoked.
We can provide some workaround if that's what you are doing at the moment
I guess you rely on the
Player.Listener.onVideoSizeChanged()callback to layout your view (the white bounds)? In short with video effects, that callback is not invoked.We can provide some workaround if that's what you are doing at the moment
Thanks for the reply.
I don't use onVideoSizeChanged() listener. i just apply the text overlay effect and do .setVideoEffects().
@claincly My issue is related to #1393 . Since i am adding a temporary effect at the beginning. Before setting prepare(). And then later on allow users to choose an effect and just do .setVideoEffects() to apply the new effect. As told in here( This process is the problem of the black bound).
Although if we don't set a temporary video effects at the beginning during the initialization. And when later on when user selects a effect. i do .setVideoEffects() but the effect doesnt shows up in the player. And we need to re initialize the player to preview the video effects as stated here (There is no black gaps problem in this process)
The issue you mentioned in #1393 seems unrelated (sorry if I closed that issue prematurely, please open a new one if setVideoEffects() don't update the effects.)
This specific issue sounds like related to view resizing. My guess is the view you use, gets resized when you are using plain ExoPlayer, but not when using effects. This is a known issue because we don't invoke the said onVideoSizeChanged() callback.
Please confirm how you set up ExoPlayer, specifically how you set the view. Are you using a PlayerView?
The issue you mentioned in #1393 seems unrelated (sorry if I closed that issue prematurely, please open a new one if
setVideoEffects()don't update the effects.)This specific issue sounds like related to view resizing. My guess is the view you use, gets resized when you are using plain ExoPlayer, but not when using effects. This is a known issue because we don't invoke the said
onVideoSizeChanged()callback.Please confirm how you set up ExoPlayer, specifically how you set the view. Are you using a
PlayerView?
@claincly Yes i am using androidx.media3.ui.PlayerView.
<LinearLayout
android:id="@+id/linear21"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical"
android:layout_weight="1">
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="@android:color/transparent"
app:cardElevation="0dp"
app:cardCornerRadius="15dp"
app:strokeWidth="2dp"
app:strokeColor="#E7DABA">
<androidx.media3.ui.PlayerView
android:id="@+id/videoview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:use_controller="false" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
I initialize player and set the video Effects for the first time when the activity loads.
ExoPlayer player = new ExoPlayer.Builder(this).build();
binding.videoview1.setPlayer(player);
MediaItem mediaItem = new MediaItemFactory().createMediaItem(myVideoUri);
player.setMediaItem(mediaItem);
player.setVideoEffects(myEffects);
player.prepare();
I get the black bounds now.
@claincly How do I solve it ?
Note this feature is not officially supported yet, but you could try to invokemaybeNotifyVideoSizeChanged(videoSize) in here:
https://github.com/androidx/media/blob/ae9a2339679826f870690092509a135dffc0d7e4/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java#L896
But of course this means you need to be building media3 from source.
@claincly will this be resolved in 1.8 beta ?
No we currently don't have immediate plans to remove this restriction. Please see if the code from above solves your issue.
No we currently don't have immediate plans to remove this restriction. Please see if the code from above solves your issue.
Sorry i am unable to build from the source.
If we don't add player.setVideoEffects(myEffects); at the beginning and later on do player.setVideoEffects(myEffects); this fixes the issue but then the effect won't be shown as the pipeline wasn't created.
Like the below:
ExoPlayer player = new ExoPlayer.Builder(this).build();
binding.videoview1.setPlayer(player);
MediaItem mediaItem = new MediaItemFactory().createMediaItem(myVideoUri);
player.setMediaItem(mediaItem);
// player.setVideoEffects(myEffects);
player.prepare();
And Later on:
player.setVideoEffects(myEffects);
So if is it possible then can we eliminate
setting player.setVideoEffects(myEffects); at the beginning and only use player.setVideoEffects(myEffects); when needed so please fix the issue that if we do this then the pipeline must be created.
This fixes the issue of black space, if we don't use player.setVideoEffects(myEffects); at the beginning.
The issue will continue to exist if you enable the processing pipeline. To get around it you need to apply the workaround mentioned above and build from source I'm afraid, but doing so might result in a slight "flash" when starting the playback.
The issue will continue to exist if you enable the processing pipeline.
Yes i noticed it still exists
I'm closing the issue for now as instruction is given in https://github.com/androidx/media/issues/2505#issuecomment-2955285217 and please re-open if there's problem with that