Friday 20 June 2014

Frame extraction from Video in Windows Phone 8.1 C# App


This Project is available on GitHub feel free to download and use it, If you have any suggestion or issue, Please post your comments in comment section.


Solution Layout:

It has following two projects :

1) VideoToolPhone (C++) : This is the main project which implements the Media Foundation interface and extracts frames.

2) TestApp (C#) : This app is to demonstrate how to use this in c# app.


I know most of the people will be interested in only c# part, so I will first explain c# app.

First you need to create an Object of FrameGenerator

frameGenerator = new VideoToolPhone.FrameGenerator(150, 90);

150 and 90 is width and height of frame size you want.

FrameGenerator has 2 events FrameGenerationCompleted and FrameGenerated. FrameGenerated fires after every frame generation and gives you file name of frame being generated. FrameGenerationCompleted fires when all frames are generated.

frameGenerator.FrameGenerationCompleted += fb_FrameGenerationCompleted; frameGenerator.FrameGenerated += frameGenerator_FrameGenerated;

Create only one instance of framegenerator in your app and don't forget to dispose it when you no longer needs it.

Next is GenerateFrames method which actually starts generating frames, you need to pass following arguments:

VideoFile : Video file from which frame needs to be extracted
Destination Folder: This is folder where all the extracted frames will be stored.
Count : Count is how many frames you want to extract. Suppose you set count as 10 for 10sec video so each frame will be extracted after 1sec.

frameGenerator.GenerateFrames(VideoFile, DestinationFolder,100 );

Snapshot

Those who are interested in c++ code please vist my next post.




3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Do you have frame extractor code (github says that there is no such page)?

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete