-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[video_player] Fixed orientation and position issue for some videos metadata. #1451
[video_player] Fixed orientation and position issue for some videos metadata. #1451
Conversation
0e4caa2
to
a6de6a7
Compare
a6de6a7
to
9d00507
Compare
Do you have a sample video to show before/after? |
I don't have one no, but what was happening is that when rotated on portrait left the video was not visible (out of the screen). Sound was working. This just adds the missing orientation (the fix for portrait up and down was already there). |
I did this fix when working on this PR for the camera plugin on iOS #1452 |
transform.tx = videoTrack.naturalSize.height; | ||
transform.ty = 0; | ||
} else if (rotationDegrees == 180) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quentinleguennec Thanks for your PR. I just tested your fix and unfortunately this line is not rendering videos taken at 180°. tx and ty must be 0 for videos in landscape and reverse landscape mode. Furthermore, some videos metadata include incorrect tx, ty values when in portrait mode. In https://github.com/flutter/plugins/pull/1307/files I've added a fix to properly display these videos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be because I was using the fixed rotation metadata from this PR: #1452
On my side with both those PRs the videos display properly. (even when the video is recorded with a rotation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried recording your videos with the native Camera app? That's the one I used to record a video in 180° that displays a black screen with tx and ty set to non 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@recastrodiaz Good point, I didn't think about checking with the native camera app.
I just did and it is working with the current code when you record a video on your iPhone and play it with the video_player. But it is not working (black screen) if you record the video from the native camera app of an Android an play it with the video_player on an iPhone.
That's because the native iPhone camera app add the translation metadata to the video file (which can be seen with ffprobe). But Android doesn't add it (and VLC doesn't need it either, just iOS).
With the fix I added it displays the video recorded on Android properly when played on an iPhone. And it also works with a video recorded from an iPhone and played on an iPhone from the video_player.
I'll drop this here while we wait for the PR review, it's a fix for the camera plugin and video plugin recording quality and rotation issues. For people interested in a fix have a look at the discussion on this issue: flutter/flutter#29951 Copy-paste, for more fixes (like issues with aspect ratio) check the previous link:
I created a branch with those 4 fixes merged together, I suggest you try this branch first and see if it works on your side: You can use it by adding this in your pubspec.yaml:
|
@quentinleguennec thank you for your contribution! Unfortunately the structure of the plugin has changed lately to support implementations on more platforms. Mainly the plugin was moved to a new subdirectory and now uses a common platform interface. Adapting your PR to the new structure should be straight forward. If you have questions please ask! Please also make sure to include tests for the new functionality. |
Currently using the ff
Issue still persists |
Thanks for the contribution! Based on the discussion above, it sounds like this PR may not actually work in isolation, which would be a blocker for moving forward with review and landing. It also would need to be updated for the changes in plugin structure as noted above. Given that, and the long period without updates, I'm going to close this, but if you're still interested in moving forward with this please do open a new PR (which should be triaged quickly under our new process) with a version that works in isolation—combining fixes if necessary. We apologize for the long delay in triaging this PR. We’re in the process of overhauling our PR triage system to respond much more quickly, as well as working through the backlog. |
Description
The video was not always displaying properly on iOS depending on the rotation metadata (iOS need the tx and ty of the transform to have an offset if the video is rotated, unlike Android or VLC). This fixes it.
Related Issues
Fixes flutter/flutter#29951
Fixes flutter/flutter#27201
Fixes flutter/flutter#29500
NOTE: The camera plugin also need an update to add rotation metadata to the recorded videos. This is done in this other PR: #1452
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?