diff --git a/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs b/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs index d6d2e5d..f97d4ae 100644 --- a/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs +++ b/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs @@ -146,6 +146,23 @@ private uint VideoFormat(out IntPtr userdata, IntPtr chroma, ref uint width, ref { var pixelFormat = IsAlphaChannelEnabled ? PixelFormats.Bgra32 : PixelFormats.Bgr32; FourCCConverter.ToFourCC("RV32", chroma); + + //Correct video width and height according to TrackInfo + var md = MediaPlayer.GetMedia(); + foreach (MediaTrack track in md.Tracks) + { + if (track.Type == MediaTrackTypes.Video) + { + var trackInfo = (VideoTrack)track.TrackInfo; + width = trackInfo.Width; + height = trackInfo.Height; + if (trackInfo.SarDen != 0) + { + width = width * trackInfo.SarNum / trackInfo.SarDen; + } + break; + } + } pitches = this.GetAlignedDimension((uint)(width * pixelFormat.BitsPerPixel) / 8, 32); lines = this.GetAlignedDimension(height, 32);