media icon indicating copy to clipboard operation
media copied to clipboard

Support reflective video transformations during ExoPlayer playback (e.g. from QuickTime/iOS MP4 files)

Open hust-twj opened this issue 11 months ago • 4 comments

Version

Media3 main branch

More version details

No response

Devices that reproduce the issue

Any device, it seems have nothing to do with device

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

  1. Change media.exolist.json file -> "Playlists" -> "Cats -> Dogs"
  2. Replace its original uri with below: "https://zh-files.oss-cn-qingdao.aliyuncs.com/20170808223928mJ1P3n57.mp4""https://wx-love-img.afunapp.com/ec34db03f040ee1cfb9cfef5c087aaf3" In fact, the two urls above are all rotated -90 degree screenshot-20250103-104814

Expected result

And the weird thing is, for "https://zh-files.oss-cn-qingdao.aliyuncs.com/20170808223928mJ1P3n57.mp4",the video frame is OK for "https://wx-love-img.afunapp.com/ec34db03f040ee1cfb9cfef5c087aaf3", the video frame is not OK, it rotates -90 degree. It should like this: screenshot-20250103-105024

Actual result

for "https://wx-love-img.afunapp.com/ec34db03f040ee1cfb9cfef5c087aaf3" , the video frame rotate -90 degree, like this image

Media

The reproducible url:"https://wx-love-img.afunapp.com/ec34db03f040ee1cfb9cfef5c087aaf3"

Bug Report

  • [ ] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

hust-twj avatar Jan 03 '25 02:01 hust-twj

@rohitjoins I feel this could be related to extractors not parsing the correct rotation? Could you take a look?

claincly avatar Jan 03 '25 13:01 claincly

@rohitjoins I feel this could be related to extractors not parsing the correct rotation? Could you take a look?

@claincly @rohitjoins Thanks in advance.

hust-twj avatar Jan 06 '25 12:01 hust-twj

Hi @hust-twj,

Thank you for your patience. I investigated the media in question and found that its transformation matrix is not purely rotational, it also involves flipping. Our current implementation assumes that the transformation matrix only represents rotation, which is why it doesn’t handle this case correctly.

Tools like ffmpeg, mediainfo, or even media players like VLC use a mathematical formula to calculate rotation based on the assumption that the transformation matrix is purely rotational. In this case, that assumption doesn’t hold, leading to incorrect rotation values and ultimately displaying the wrong output since the video should also be flipped.

I’ll mark this issue as a feature request to add support for flipping using the transformation matrix. Thanks for reporting this!

Here’s a comparison of VLC (incorrect) vs. QuickTime (correct):

Image

rohitjoins avatar Jan 16 '25 17:01 rohitjoins

The commit linked above makes ExoPlayer behave like VLC - so these videos are now the right way up, but still incorrectly mirrored in the y-axis. Resolving the mirroring issue is a bit more complicated. I will re-title this issue to reflect that's what it's tracking.

icbaker avatar Jun 16 '25 07:06 icbaker