media icon indicating copy to clipboard operation
media copied to clipboard

Black Bounds when setVideoEffects

Open ranjitsingha opened this issue 8 months ago • 7 comments

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)

Image

But when i remove the player.setVideoEffects or set it to player.setVideoEffects(null) i get no problem.

Image

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 bugreport to [email protected] after filing this issue.

ranjitsingha avatar Jun 05 '25 04:06 ranjitsingha

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

claincly avatar Jun 05 '25 12:06 claincly

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().

ranjitsingha avatar Jun 05 '25 13:06 ranjitsingha

@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)

ranjitsingha avatar Jun 06 '25 04:06 ranjitsingha

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 avatar Jun 06 '25 10:06 claincly

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.

ranjitsingha avatar Jun 06 '25 11:06 ranjitsingha

@claincly How do I solve it ?

ranjitsingha avatar Jun 07 '25 14:06 ranjitsingha

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 avatar Jun 09 '25 09:06 claincly

@claincly will this be resolved in 1.8 beta ?

ranjitsingha avatar Jun 25 '25 15:06 ranjitsingha

No we currently don't have immediate plans to remove this restriction. Please see if the code from above solves your issue.

claincly avatar Jun 25 '25 15:06 claincly

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.

ranjitsingha avatar Jun 25 '25 16:06 ranjitsingha

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.

claincly avatar Jun 25 '25 16:06 claincly

The issue will continue to exist if you enable the processing pipeline.

Yes i noticed it still exists

ranjitsingha avatar Jun 30 '25 05:06 ranjitsingha

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

claincly avatar Jul 03 '25 08:07 claincly