Search code examples
c#vlclibvlclibvlcsharp

Taking snapshot Vlc.DotNet.Form to variable Bitmap in C#


We need to processing image in C# from UDP video stream. in project we can get image and save it to Path With vlcControl. We need to have this image in a variable and not inside a file on the hard drive. Please see my code below:

vlcControl1.TakeSnapshot(@"D:\a.jpg", 600, 400);

Now we need to have an address in memory or override a method to solve the problem.

We tried to create an address in memory and another override a method TakeSnapshot


Solution

  • In libvlc3/LibVLCSharp3, there is no way to get a snapshot in memory. If you want all frames in memory, you could consider this option instead : https://code.videolan.org/mfkl/libvlcsharp-samples/tree/master/PreviewThumbnailExtractor

    In LibVLC4, still in prerelease, there is an APi for that : https://mfkl.github.io/libvlc/2020/07/23/Gracefully-surfacing-asynchronous-C-APIs-to-.NET.html

    From that blog post, you can see the following lines used to create a snapshot :

    using var media = new Media(libVLC, new Uri("C:\\Path\\To\\Videos\\big_buck_bunny_720p_30mb.mkv"));
    using var thumbnail = await media.GenerateThumbnail(time: 200, 
                                    speed: ThumbnailerSeekSpeed.Fast, 
                                    width: 200, 
                                    height: 200, 
                                    crop: false, 
                                    pictureType: PictureType.Argb);