当前位置: 动力学知识库 > 问答 > 编程问答 >

Extract keyframe from flv using C#

问题描述:

Is there a way to extract a keyframe from flv file using C#?

网友答案:

Can't find a direct way of doing this.

However you can use FFmpeg.exe in C#.

Here you can find a C# wrapper to easily use FFmpeg in C#:

http://www.ffmpeg-csharp.com/

The following code is taken from their sample page. Seems like you can extract frames and create thumbnails from them in the following manner:

CAVConverter converter = new CAVConverter();
//...

Use converter.AVPrope.Decode(-1) to decode the next frame and converter.AVPrope.CurrentPicture to get the thumbnail picture. Use converter.AVPrope.SaveCurrentFrame(fileName) to save current frame to the file fileName.

//Load the file
converter.AVPrope.LoadFile(fileName, "");
//Decode the frame converter.AVPrope.Decode(-1);
//Get the thumbnail picture. It is a IPictureDisp object, do something as you need.
var thumbnail = converter.AVPrope.CurrentPicture;
//Save current frame to file fileName
converter.AVPrope.SaveCurrentFrame(fileName);

Hope it helps.

分享给朋友:
您可能感兴趣的文章:
随机阅读: