LEADTOOLS Media Foundation SDK使用方法

随着越来越多的人采用了最新的Windows操作系统,Microsoft Media Foundation正在迅速抬头。自LEADTOOLS V18发布以来, Media Foundation SDK便受到越来越多客户的亲睐。

LEADTOOLS v18包含了众多能处理核心多媒体功能的控件,如播放,捕获和转换等,此外,还包含一些视频和音频的特殊处理功能。LEADTOOLS中最流行、最灵活的转换就是视频转换回调,允许你直接访问原始视频数据。

下列代码显示播放视频文件并将帧作为JPEG保存至磁盘:

// Initialize the Callback Transform after setting up the play control
private void AddCallback(object pCallback)
{
if (lmvCallBkPlay == null)
{
playCtrl1.SelectedVideoProcessors.Add(playCtrl1.VideoProcessors.Callback);
lmvCallBkPlay = playCtrl1.GetSubObject(Leadtools.MediaFoundation.PlayObject.SelVideoProcessor) as LMFVCallback;
lmvCallBkPlay.ReceiveProcObj = pCallback;
fCallbackFilterInserted = true;
}
else
{
lmvCallBkPlay.ReceiveProcObj = pCallback;
fCallbackFilterInserted = true;
}
}

// Code for the Callback Transform
public class LEADCallbackPlay : ILMVUserCallback2
{
public LEADCallbackPlay(){ }
~LEADCallbackPlay(){}

public void ReceiveProc(long pData, int lWidth, int lHeight, int lBitCount, int lSize, int bTopDown)
{
Bitmap bmp = new Bitmap(lWidth, lHeight, lBitCount / 8 * lWidth, System.Drawing.Imaging.PixelFormat.Format32bppRgb, new IntPtr(pData));
bmp.Save("Still_bitmap.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
}

你可能感兴趣的:(LEADTOOLS)