How to maintain aspect-ratio when playing RTSP str

2019-07-27 15:31发布

问题:

I have a streaming RTSP video link which I am playing with the help of VideoView. In the portrait mode the Video resolution and aspect ratio is perfect. But when I try switching to the landscape mode the video stretches and looks elongated. This distorts the quality to a great deal.

  1. Any tips of how to make the videoview to maintain the same aspect ratio in both orientation modes?
  2. If i need to write my own media player extending the VideoView .. How exactly should I override the onMeasure(...) to render the video properly? any example will be of great help coz of the limited documentation on android developer site
  3. How to find the size of the video received through RTSP? so that we can set the videoview to that size?

If any suggestions I am open to listen as I am quite new to the Media API....

回答1:

Any tips of how to make the videoview to maintain the same aspect ratio in both orientation modes?

It normally does. This project, for example, works properly with a local test.mp4 file (in the root of external storage) in portrait and landscape, while maintaining aspect ratio.