androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.51k stars 358 forks source link

Picture in Picture overlay in Exoplayer #806

Open pawaom opened 9 months ago

pawaom commented 9 months ago

For Bitmap or Drawable overlay we use this code

OverlaySettings logoSettings =
                new OverlaySettings.Builder()  .build();
        Drawable logo = getPackageManager().getApplicationIcon(getPackageName());
        logo.setBounds(
                /* left= */ 0, /* top= */ 0, logo.getIntrinsicWidth(), logo.getIntrinsicHeight());
        TextureOverlay logoOverlay = DrawableOverlay.createStaticDrawableOverlay(logo, logoSettings);

        overlaysBuilder.add(logoOverlay);
        ImmutableList<TextureOverlay> overlays = overlaysBuilder.build();

          return overlays.isEmpty() ? null : new OverlayEffect(overlays);

While checking the code we could find the Bitmapoverlay

and the

DrawableOverlay

What is the video overlay equivalent for video overlay , We tried using bitmap overlay

like this

 OverlaySettings logoSettings = new OverlaySettings.Builder()
                    .setScale(.25f, .25f)
                    .setOverlayFrameAnchor(1, -1)
                    .setBackgroundFrameAnchor(.9f, -.7f)
                    .build();

            TextureOverlay logoOverlay = BitmapOverlay.createStaticBitmapOverlay(this,OverLayVideoUri, logoSettings);

            overlaysBuilder.add(logoOverlay);
            ImmutableList<TextureOverlay> overlays = overlaysBuilder.build();
         outputPlayer.setVideoEffects(Collections.singletonList(new OverlayEffect(overlays)));

But nothing was rendered

There few more questions we would like to know

1) how do we apply separate effects for individual videos, say we have 3 different videos for each video we want separate effects, like we rotate first video, grayscale second video, and crop third video how can we do this and render it in exoplayer

2) How to adjust the width and height of various videos, like in previous example we have first video of 854 x 480 , second is 1280 x 720 and third is 426 x 240 we want all these videos to be rendered and transformed to 1280 x 720 how can we do this

3)some thing related to above question render different aspect ratios like, 4:3, 16:9 etc

while Transform has the options to use

EditedMediaItem

which provides better option to have changes specific to a particular video

While the setVideoEffects provides options to apply effect to videos , it seems to apply at the exoplayer level to all videos instead of to a specific video, it will be great if we have similar option like EditedMediaItem for exoplayer also.

pawaom commented 9 months ago

Is this really not possible, I have been waitng for 3 days for an answer, but seems nobody is even assigned to this question

droid-girl commented 9 months ago

@pawaom let me start to address some of your questions first:

  1. At the moment it is not possible to apply separate effects to individual videos in ExoPlayer by using setVideoEffects. The team is working on it.

Are you using ExoPlayer to preview the editing output before export?

pawaom commented 9 months ago

Are you using ExoPlayer to preview the editing output before export?

yes We are trying to use ExoPlayer to preview the editing output, I know there is the option to use this

or we can use the GlSurfaceview, But exoplayer provides all the other options that we need to specially for the effects that we want to use specially BitmapOverlay, DrawableOverlay, GLShaders etc just for the PIP video overlay we might have to use a different mechanism,

for the individual video being able to have its own effects we can wait until there is a inbuild mechanism, ( Hopefully soon )

However if there is a inbuild mechanism for the PIP video effect it will be useful for us, at least if we know how to use some existing code to use this feature it will be really helpful

pawaom commented 9 months ago

any suggestion how can I show the PIP video effect, in exoplayer

We want to show the Live edit effects as we make the changes, As far as this is concerned do we have to transform the video first or can we use it directly, we tried to call the DemoDebugViewProvider direclty but it didnot render anything

If we have to use glsurfaceview it is just duplication of work, which has already been done in DefaultVideoCompositor