Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Transformer Demo video is initially clipped after export #172

Closed
2 tasks done
calren opened this issue Jun 14, 2024 · 4 comments · Fixed by #177
Closed
2 tasks done

[Bug]: Transformer Demo video is initially clipped after export #172

calren opened this issue Jun 14, 2024 · 4 comments · Fixed by #177
Labels
bug Something isn't working

Comments

@calren
Copy link
Contributor

calren commented Jun 14, 2024

Is there an existing issue for this?

  • I have searched the existing issues

In which area is the issue?

General

In a specific sample?

Transformer Video

What happened?

After exporting a video composition, the video played is not properly sized in the video player, and appears clipped.

If you exit the app and come back, the video sizing and positioning is fixed.

This seems like a problem when an exoplayer view is first created without a video set, and when the video is set ExoPlayer doesn't resize and position the video properly.

exoplayer_bug.mp4

Relevant logcat output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@calren calren added the bug Something isn't working label Jun 14, 2024
@calren
Copy link
Contributor Author

calren commented Jun 14, 2024

@droid-girl Any idea why this might be happening? Feels like the code might be missing something in between setting the mediaItem on the exoplayer and preparing exoplayer for playback (https://github.com/android/platform-samples/blob/main/samples/media/video/src/main/java/com/example/platform/media/video/TransformerVideoComposition.kt#L261-L272), but I can't figure out what's missing. Hoping someone on the ExoPlayer team can help debug.

@calren calren changed the title [Bug]: Transformer Demo video is initially clipped [Bug]: Transformer Demo video is initially clipped after export Jun 14, 2024
@calren
Copy link
Contributor Author

calren commented Jun 17, 2024

From Kristina: Maybe we should try AspectRatioLayout, ie: https://github.com/androidx/media/blob/d833d59124d795afc146322fe488b2c0d4b9af6a/demos/transformer/src/main/res/layout/transformer_activity.xml#L88

I will give this a try and see if the issue persists.

@calren
Copy link
Contributor Author

calren commented Jun 17, 2024

I got the issue resolved by:

  1. Putting PlayerView inside AspectRatioFrameLayout
    <androidx.media3.ui.AspectRatioFrameLayout
        android:id="@+id/input_debug_aspect_ratio_frame_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.media3.ui.PlayerView
            android:id="@+id/media_player"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </androidx.media3.ui.AspectRatioFrameLayout>
  1. Explicitly setting aspect ratio in the Activity / Fragment
    binding.inputDebugAspectRatioFrameLayout.setAspectRatio(16f/9f)

Will submit a PR for this fix.

This doesn't seem very intuitive, so I will explore ways we can make this easier for the developer.

@calren
Copy link
Contributor Author

calren commented Jun 20, 2024

After more investigating, this seems to be a Compose-related issue. When the sample was isolated to only use Views (https://github.com/calren/ViewsTransformerExoPlayerDemo), the issue was no longer present.

The Compose issue is being tracked here: androidx/media#1237 . Using the 1.4.0-rc01 version of PlayerView should resolve this issue. Once Media3 1.4.0-rc01 is released, I will update the Media3 dependency and test again.

In the mean time, I don't think we need to merge the fix that involves using AspectRatioFrameLayout, so I will close #173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant