3

I need a C# library that allows to read video frames starting not from the beginning of a video.

For example, I want to get the 400-th frame. I'd like something that provides a clear way to do this, like:

grabber.GetFrameByNumber(400);

Any suggestions?

Thanks in advance :)

1
  • Do you want to redistribute your program? If yes, with what license?
    – Nicolas Raoul
    Commented Nov 16, 2016 at 10:24

2 Answers 2

3

If you are looking for a commercial library to use for this, I recommend checking out the LEADTOOLS Multimedia SDK. The LEADTOOLS Multimedia SDK is developed around the Microsoft DirectShow or Media Foundation libraries.

You can use the LEADTOOLS PlayCtrl to load the video, navigate to the frame you wish to get the image from, then give you the image at that particular frame location. This can be done in just a few lines of code:

PlayCtrl playCtrl = new PlayCtrl();
playCtrl.SourceFile = @"Path the video file";
playCtrl.Run();
playCtrl.CurrentFramePosition += 399;
Image image = playCtrl.GetStillImage(0);
image.Save(@"Path to save image location", ImageFormat.Bmp);

Please note that I am an employee of this product.

1

I suggest Libvlc.Net

Example code:

string filePath = GetTemporaryFilePath();
PlayerOutput output = new PlayerOutput();
output.Files.Add(new OutFile(filePath));
player = (Player)factory.CreatePlayer (output);
player.SetMediaInput(new MediaInput (MediaInputType.File, "/Users/rz/Movies/SampleMovie.mp4"));
player.Play();

You can implement your own PlayerOutput that just keeps the frame you want.

To save processing time you can make the player jump to a particular position before getting the frames. Be careful with time-to-frames conversion.

License: GNU GPL, same as the VLC player.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.