You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How can I get the actual web video width and height? #3690
We use ExoPlayer version 'r2.4.4' to show videos from Giphy to users. It looks like sometimes a metadata of incoming videos is not correct. We use standard VideoListener to make our video fullscreen achieving "Center crop" effect. As a result, our videos appear "squeezed". The question is if there is a way to get actual video dimensions (because the video is shown correctly in ExoPlayer itself). Also, screenshots from MacBook file info showing correct dimensions of the same file are attached. Another screenshot shows Video debug panel of ExoPlayer demo app that shows incorrect dimensions (152x200) with a strange pixels ratio (1.73).
Reproduction steps
We use usual video listener to get width and height.
exoPlayer.setVideoListener(new VideoListener() {
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
float pixelWidthHeightRatio) {
viewerSurfaceView.setVideoSize(height, width);
presenter.onVideoSizeChanged(width, height);
}
@Override
public void onRenderedFirstFrame() {
super.onRenderedFirstFrame();
exoPlayer.
}
});
The video resolution really is 152x200 pixels, but the pixels are not square (indicated by pixelAspectRatio being not equal to 1). VLC also reports this resolution. You need to fix your code to take pixelAspectRatio into account. Note that:
(width * pixelAspectRatio) = (152 * 1.73) = 263
so the Macbook file info is actually showing the width in pixels multiplied by the pixelAspectRatio.
Activity
ojw28 commentedon Jan 10, 2018
The video resolution really is 152x200 pixels, but the pixels are not square (indicated by pixelAspectRatio being not equal to 1). VLC also reports this resolution. You need to fix your code to take pixelAspectRatio into account. Note that:
so the Macbook file info is actually showing the width in pixels multiplied by the pixelAspectRatio.