Extract frames from video files – The Code Project – Multimedia


 

Introduction

This class contains methods to use the IMediaDet interface, that can be found in Microsoft DirectShow.
The Media Detector object, among other things, can be used to extract still pictures from several file formats including .avi, .wmv and some .mpeg files. This class exposes the GetFrameFromVideo, GetVideoSize and SaveFrameFromVideo methods that can be used from any .net application. The class also takes care of translating HRESULTs returned from the functions to meaningful .net exceptions.

Using the code

Just add a reference to JockerSoft.Media.dll in your project (or include the source code). Remember also to distribute Interop.DexterLib.dll  All the methods are static, so to use them just do something like

try
{
    this.pictureBox1.Image = FrameGrabber.GetFrameFromVideo(strVideoFile, 0.2d);
}
catch (InvalidVideoFileException ex)
{
    MessageBox.Show(ex.Message, "Extraction failed");
}
catch (StackOverflowException)
{
    MessageBox.Show("The target image size is too big", "Extraction failed");
}

or

try
{
    FrameGrabber.SaveFrameFromVideo(strVideoFile, 0.2d, strBitmapFile);
}
catch (InvalidVideoFileException ex)
{
    MessageBox.Show(ex.Message, "Extraction failed");
}

Via Extract frames from video files – The Code Project – Multimedia

Advertisements

12 thoughts on “Extract frames from video files – The Code Project – Multimedia

  1. Is there a way to extract frames in silverlight? I tried using the FrameGrabber technique but the dlls are not allowed to be added to the project as they are not built for silverlight

  2. I almost never comment, however i did some searching and wound up here Extract frames from video files – The Code Project
    – Multimedia Vincent Leung .NET Tech Clips. And I do have some questions for you if it’s allright. Could it be simply me or does it give the impression like some of the responses look like written by brain dead people? 😛 And, if you are posting on other places, I’d like to follow everything
    new you have to post. Would you make a list of every one of your shared sites like your Facebook page, twitter feed,
    or linkedin profile?

  3. I do not even know how I ended up here, but I thought this post was
    great. I do not know who you are but definitely you are going to a famous blogger if you
    aren’t already 😉 Cheers!

  4. Hi there! I understand this is somewhat off-topic however
    I needed to ask. Does operating a well-established blog like yours
    take a massive amount work? I’m brand new to operating a blog however I do write in my diary on a daily basis. I’d like to start a
    blog so I can share my experience and views online. Please let
    me know if you have any kind of recommendations or tips for new aspiring blog owners.
    Appreciate it!

  5. Hey! Quick question that’s completely off topic. Do you know how to make your site mobile friendly? My blog looks weird when browsing from my apple iphone. I’m trying to
    find a theme or plugin that might be able to fix this problem.
    If you have any recommendations, please share. Many thanks!

  6. I simply could not leave your website prior to suggesting that I really loved the usual
    information a person provide to your guests?

    Is gonna be bak incessantly to check up on new posts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s