VLC.Dotnet.WPF control stretches portrait video. How can I get the control to not stretch the video

1k Views Asked by At

VLC.Dotnet.WPF control stretches portrait video. How can I get the control to not stretch the video. Landscape videos play fine, its when I have a video recorded on a phone e.g. .mov in portrait mode it stretches the video.

How can I play the video without being stretched? Is there an option I can pass through the CreatePlayer method?

.xaml

<Grid>
   <vlc:VlcControl x:Name="MediaPlayerOne"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center" />
</Grid>

.cs

        var currentAssembly = Assembly.GetEntryAssembly();
        var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
        // Default installation path of VideoLAN.LibVLC.Windows
        var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));

        MediaPlayerOne.SourceProvider.CreatePlayer(libDirectory);
        MediaPlayerOne.SourceProvider.MediaPlayer.Play(new Uri("text.mov"));
2

There are 2 best solutions below

3
mfkl On

You can try various aspect ratios like this

MediaPlayerOne.Video.AspectRatio = "4:3";
MediaPlayerOne.Video.AspectRatio = "16:9";
3
cube45 On

Either there is an issue here https://github.com/ZeBobo5/Vlc.DotNet/blob/develop/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs or libvlc doesn't send the correct ratio for the video (i.e. original dimensions before rotation, while you're expecting the opposite). Can you try to clone Vlc.DotNet and investigate further?