0

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"));
mfkl
  • 1,914
  • 1
  • 11
  • 21
Mmedi005
  • 35
  • 7

2 Answers2

0

You can try various aspect ratios like this

MediaPlayerOne.Video.AspectRatio = "4:3";
MediaPlayerOne.Video.AspectRatio = "16:9";
mfkl
  • 1,914
  • 1
  • 11
  • 21
  • When I type that I get Video not being found, but I can find it by typing MediaPlayerOne.SourceProvider.MediaPlayer.Video.AspectRatio = "4:3"; but with this I'm having no luck. If I use LibVLCSharp.WPF it showed correctly but I was having airspace issues where I have grids that can be dragged around not being able to go in front of the video. The Vlc.DotNet.WPF control takes care of the airspace issue but now I ran into .mov video recorded in portrait being stretched. – Mmedi005 Mar 15 '21 at 13:38
  • I can send you the file if you like to test @mfkl – Mmedi005 Mar 15 '21 at 14:50
  • @mfkl Vlc.DotNet.Wpf doesn't respect AspectRatio : https://github.com/ZeBobo5/Vlc.DotNet/issues/375 – cube45 Mar 15 '21 at 20:39
0

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?

cube45
  • 3,429
  • 2
  • 24
  • 35
  • Using the example in the link I run into the airspace issue. After banging my head I imported the mov again and its working as it should. No idea why this working now but will look into it after I clone. – Mmedi005 Mar 16 '21 at 01:04
  • just trying to manipulate any properties and doesnt seem to update the media player. I tried turning off Spu by setting it to -1 and nothing happens. If I use the VideoView control from LibVLCSharp.WPF the properties look like they are being set when changed, e.g. SetSpu(-1). Any ideas? – Mmedi005 Mar 16 '21 at 15:32
  • That's not how it works. The target dimensions are computed by the code to allocate a buffer for the bitmap,which is then swapped N times per seconds. It seems the values for width and height we receive from libvlc are swapped (or not rotated if you wish). There is investigation to be done on whether we can do something smart about it or if we should report the bug to libvlc – cube45 Mar 16 '21 at 19:20