-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Rotation issue #91
Comments
Hm. This is pretty easy to fix on Lollypop. It actually already rotates the video on Lollypop, the only thing that's still wrong is that the video dimensions aren't also swapped (for 90 and 270 degree). Pre-Lollypop any fix is going to be more difficult, because MediaExtractor doesn't parse out the video rotation. |
So let's mark the issue as a bug. Because the behavior is not as expected and it is possible to fix it somehow. |
in the mean time you can use mediametadataretriever to get the rotation and a textureview and apply a transform to the texture pretty easily (thanks ojw for the hint) |
@ojw28 Is it possible to do so by parsing rotation using MediaMetadataRetriever? Would love to stick to SurfaceView as the only advantage that we seem to get from using TextureView would be the right rotation. |
We're also having issues with this lack of functionality. |
ExoPlayer has a bug (google/ExoPlayer#91) that requires us to manually detect the orientation of a video and transform the TextureView. The fix is encapsulated in VideoOrientationPatcher; that class should be removed when ExoPlayer gets fixed. On API 16 and below: - Video orientation must be read using a third-party library, e.g. mp4parser On API 17 and above: - Video orientation can be read using MediaMetadataRetriever On API 20 and below: - ExoPlayer does not rotate the video automatically On API 21 and above: - ExoPlayer rotates the video automatically On all API levels: - Reported video dimensions in onVideoSizeChanged must be swapped if the video is portrait
Same problem here. |
Any plans on fixing this? |
I would argue this is a MediaCodec/libstagefright bug not an ExoPlayer bug as MediaCodec is what's doing the rendering. ExoPlayer is just managing the samples and timing. Also this is evident in the Lollipop libstagefright fix in which it respects the rotation (which screws things up for my use and I had to add this to counteract it)
|
Has anyone seen whether it's still an issue if you're using the MP4 support currently in development? It's currently available on the |
Pulling the extractor up to ExoPlayer wont fix the issue, because the issue is in the decoder (not being pulled up) not the extractor (being pulled up). |
So what would be the recommended way to solve this? The TextureView instead of SurfaceView approach like Inikkila kindly posted? |
Hi @IanDBird @ryango "rotation-degrees" is defined in the ACodec, but it's hidden. "rotation-degrees" is available in Android 5.0, not for Android KK. |
This is another update for rotate by demo app |
The behavior has been fixed as far as is possible in the change above. Background: The underlying platform changed in Lollypop to start automatically applying rotation when decoding video into a surface. Prior to Lollypop the rotation was not applied. Since it's not possible to perform the rotation at the application level when using SurfaceView, the Lollypop+ behavior is the correct long term solution. Solution: After the change above, on Lollypop+ the rotation will always be applied correctly. On earlier versions of Android the rotation will not be applied, however the player will now report the unapplied rotation through the MediaCodecVideoTrackRenderer listener: ExoPlayer/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java Line 74 in d3995ea
This allows an application using TextureView to easily apply the rotation by making the appropriate call to TextureView.setTransform. Note that on Lollypop+ unappliedRotationDegrees will always be equal to 0. |
Thanks @ojw28 , you complete the solution. |
Is there a snapshot/dev repo to test this quickly in our app? or when will it get released ? |
You can get the latest source from the dev branch and build it yourself (or include the source directly in your project). We don't provide jar/aar binaries prior to release. Note that the APIs (in general - nothing specific to rotation) are a little unstable on the dev brach due to the arrival of multi-track support, so if you go down this route please be aware that they may change again before the next release. |
From dev I had other issues so finally I cherry-picked the changes + had to do extra changes that I took from dev to make it work: |
@ojw28 Just a small remark - the automatic applying of video orientation while decoding to a surface is true only for the default hardware decoder - when using software decoding for example (using OMX.google.h264.decoder) it does not apply rotation even on Lollipop+. |
Urgh, this is a bit of a mess at the platform level. Application of rotation is inconsistent between both API levels (pre-L v.s. L+) and (in L at least) between decoders at a fixed API level. It appears that on M+ OMX.google.h264.decoder does actually apply the rotation, but you're correct in noting that this does not happen when running L. Unfortunately, as of now, there's no easy way to determine whether a decoder has actually applied the rotation. I'm not sure how consistent the application of rotation is between decoders in M. I'll be pushing for more consistent application of rotation (if this hasn't happened already) and/or the ability to determine whether the rotation was applied in the next platform release. For ExoPlayer, always propagating the rotation value doesn't seem like the right thing to do. That just moves the problem of working out what to do from the library to every individual application developer, who will then each have to figure out what different decoders do on different API levels. Instead, I think we probably want to work out what the current behaviors are and hardcode these inside the library, so that the rotation delivered to the application always ends up being correct (i.e. 0 when using a decoder that applied the rotation, non-zero otherwise). Hopefully we can also get consistent behavior across all video decoders from some version of the platform and above, since this makes the developer's life significantly easier. Re-opening for tracking. First step is to try and figure out exactly what behavior we should be expecting across the various API levels / decoder implementations. |
Sounds good. Good luck :) On Tue, Sep 1, 2015 at 3:46 PM, ojw28 notifications@github.com wrote:
|
Do we have any timeline for fixing this issue? |
For most cases it is fixed already (the rotation will be applied, or the rotation that needs to be applied will be propagated as unappliedRotationDegrees). So it's unclear exactly what you mean by this. Unless you've modified the player to use a software decoder then I think behavior should be correct already. |
I have the same issue, please any solution ? |
I see the same issue with the latest ExoPlayer version, |
So there was no ways to rotate a SurfaceView? |
Any update on this? I'm working on a commercial app and we kinda need this fixed ASAP. Would we see a fix anytime soon or would it be better to switch to a different solution for video playback? |
same issue here. my videos playback correcly using any web or android video player that i try. But when playing back using exoplayer the videos are flipped 90 degrees on some phones. Will this be fixed soon? |
Same issue. Is any update on pre-L rotation? |
Considering I didn't see a fix, I moved to media player....The default solution for video playback. Would like to see a fix though |
ya am to moved to media player. thanks |
|
@Saqrag your code makes correct rotation for the video in pre- lollipop versions ? |
plz support display matrix rotation, like
|
Why doesn't SimpleExoPlayerView handle the rotation on older device? It already listens to the |
We could (and probably should) do this if the |
@botaydotcom - Might be fun to take a look at. |
Hi guys! Any update on this? Thank you! |
We have updated |
If SimpleExoPlayer is using TextView as output, we can handle video rotation by automatically applying a matrix transformation to the TextureView when we have this information available from the video (from video's metadata). GitHub: #91 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=180925571
The change @botaydotcom mentions has now been pushed to |
I have an application where I am using MediaRecorder to record a video and play it back using ExoPlayer. The video is recorded only in Portrait mode. I am setting the camera setRotation and MediaRecorder setOrientationHint appropriately, yet in some phones the video gets played in landscape mode. I have checked the meta data of both the files where there is a rotation issue and where there is not and I can see that the rotation is indeed getting set to 270 degree as expected and I am still not getting the desired output. The one on the left doesn't get played in correct orientation and the one on the right gets played. This is not specific to any particular API level. |
@botaydotcom great, that you have updated textureView. |
It's unfortunately not possible to do from application level (including from within ExoPlayer library) with If you use |
Example of the test video:
https://drive.google.com/file/d/0B9_5dr6in8cWcmlGZlJrSlhHS1U/view?usp=sharing
Metadata of the mp4 contains a property:
Rotation : 90°
but it's ignored by the exo player.
The text was updated successfully, but these errors were encountered: