I am playing a 720x480 video that is supposed to be shown at 16x9. It is showing vertically compressed as if it used square pixels. I added a VideoListener with onVideoSizeChanged method. That method is called with the correct values of 720 480 1.1851852. A strange thing is that if I set a breakpoint in that method, when it hits the breakpoint during start of play, the video is showing and playing at the correct shape, but as soon as that method is allowed to continue, the video shifts to the wrong size. This problem exists with the sample code at https://github.com/android/tv-samples/tree/master/Leanback on which I am basing my application.
I tried calling view.setScaleX(pixelWidthHeightRatio); in the onVideoSizeChanged callback, see below. That caused the video to shift left but still have the wrong aspect ratio.
I tried adding setting the video scaling code but I believe that is set by default anyway.
After mPlayer is created -
mPlayer.addVideoListener(new MyVideoListener());
listener class
private class MyVideoListener implements VideoListener {
@Override
public void onVideoSizeChanged(int width, int height,
int unappliedRotationDegrees, float pixelWidthHeightRatio) {
SurfaceView view = getSurfaceView();
float scaleX = view.getScaleX();
if (scaleX != pixelWidthHeightRatio)
view.setScaleX(pixelWidthHeightRatio);
}
}
There was a bug in the exoplayer leanback extension. I submitted a pull request to fix it here: github.com/google/ExoPlayer/pull/6578 . This pull request has now been committed to Excoplayer and the problem is solved.