I want to try a code sample for libvlcsharp, found here: https://code.videolan.org/mfkl/libvlcsharp-samples/-/blob/master/PreviewThumbnailExtractor/Program.cs#L113
I want to try it in a Framework 4.6.1 project, but the sample is targeted at .NET 6. I am having trouble getting one line to compile. The section in question is here:
    private static async Task ProcessThumbnailsAsync(string destination, CancellationToken token)
            {
                var frameNumber = 0;
                while (!token.IsCancellationRequested)
                {
                    if (FilesToProcess.TryDequeue(out var file))
                    {
                        using (var image = new Image<SixLabors.ImageSharp.PixelFormats.Bgra32>((int)(Pitch / BytePerPixel), (int)Lines))
                        using (var sourceStream = file.file.CreateViewStream())
                        {
                            var mg = image.GetPixelMemoryGroup();
                            for(int i = 0; i < mg.Count; i++)
                            {
                                sourceStream.Read(MemoryMarshal.AsBytes(mg[i].Span));
                            }
    
                            Console.WriteLine($"Writing {frameNumber:0000}.jpg");
                            var fileName = Path.Combine(destination, $"{frameNumber:0000}.jpg");
                            using (var outputFile = File.Open(fileName, FileMode.Create))
                            {
                                image.Mutate(ctx => ctx.Crop((int)Width, (int)Height));
                                image.SaveAsJpeg(outputFile);
                            }
                        }
                        file.accessor.Dispose();
                        file.file.Dispose();
                        frameNumber++;
                    }
                    else
                    {
                        await Task.Delay(TimeSpan.FromSeconds(1), token);
                    }
                }
            }
The troublesome line is :
sourceStream.Read(MemoryMarshal.AsBytes(mg[i].Span));
In .NET 6 there are two overloads,
Read(Span) Reads all the bytes of this unmanaged memory stream into the specified span of bytes.
Read(Byte[], Int32, Int32) Reads the specified number of bytes into the specified array.
but in .NET Framework 4.x there is just one
Read(Byte[], Int32, Int32)
I am having trouble understanding what is going on here, can someone please suggest a way to convert the line from the Read(Span) style to the Read(Byte[], Int32, Int32) style so that it works the same? I don't have experience with C#.
Thanks for any advice.
 
    