LibVLCSharp: Why does RTSP stream's aspect ratio not change when setting AspectRatio and Scale?

56 Views Asked by At

I'm using LibVLCSharp and the VideoView control from LibVLCSharp.WinForms to display RTSP streams using Windows Forms. I'm having trouble setting the AspectRatio. I implemented a method to set the AspectRatio based on my configuration given in aspectRatio:

public void SetAspectRatio(eAspectRatio aspectRatio)
{            
    if (_mediaPlayer != null)
    {
        switch (aspectRatio)
        {
            case eAspectRatio.Original:
                _mediaPlayer.AspectRatio = null;
                _mediaPlayer.Scale = 1;
                break;

            case eAspectRatio._4_3:
                _mediaPlayer.AspectRatio = "4:3";
                _mediaPlayer.Scale = 0;
                break;

            case eAspectRatio._16_9:
                _mediaPlayer.AspectRatio = "16:9";
                _mediaPlayer.Scale = 0;
                break;

            case eAspectRatio.Fill:
                _mediaPlayer.Scale = 0;
                _mediaPlayer.AspectRatio = $"{videoView.Size.Width}:{videoView.Size.Height}";
                break;

            case eAspectRatio.BestFit:
                _mediaPlayer.AspectRatio = null;
                _mediaPlayer.Scale = 0;
                return;
        }
    }
}

I took the code from this example. I'm using this method at several places in my code, mostly when an update of the aspect ratio is necessary, e.g. right before and after the stream was started or when the window is resized. Unfortunately this method does not work, the output video aspect ratio does not change in any way. Is it possible that the displayed stream does not support changing the AspectRatio? Or are there any other things I need to consider when changing/updating the AspectRatio?

I'm using pre-release versions of all LibVLCSharp components:

  • LibVLCSharp: 4.0.0-alpha-20240110-7429
  • LibVLCSharp.WinForms: 4.0.0-alpha-20240110-7429
  • VideoLan.LibVLC.Windows: 4.0.0-alpha-20240116

Any help concerning this issue would be much appreciated. Unfortunately I can't find any issues reagrding this topic in the official LibVLCSharp repository as well.

0

There are 0 best solutions below