Intel MSDK 是 Intel 公司提供的基于硬件加速功能的多媒体开发框架,通过 Intel 显卡的硬件加速功能(Intel® Quick Sync Video),可实现快速视频转码和图像处理。
- 硬编码格式:HEVC(h.265),AVC(h.264),MPEG-2,JPEG
- 硬解码格式:HEVC,AVC,VP8,MPEG-2,VC1,JPEG,MJPEG
- Filter:颜色空间转换,去隔行,降噪,缩放,旋转
Key Specifications (支持的硬件平台,操作系统,编译器等) 请参考 Intel 官网。
Intel MSDK samples
Sample Name | Description |
---|---|
Transcoding | sample_multi_transcode Transforms an elementary video stream from one compressed format to another. |
Encoding | sample_encode Converts raw video frames into an elementary compressed stream. |
Decoding | sample_decode Transforms a compressed video stream into raw frames using HEVC decode and VP8 decode. The plug-in and the included sample_decvpp demonstrate decode functions with color conversion of raw video sequences. |
Video Processing | sample_vpp Demonstrates how to use algorithms that process raw frames using denoising, deinterlacing, inverse telecine, and color conversion techniques. |
OpenCL™ Video Motion Estimation (VME) | ocl_motion_estimation Provides step-by-step guidelines on using Intel’s motion estimation extension for the OpenCL standard. The motion estimation extension includes a set of host-callable functions for frame-based VME. |
OpenCL™ Interoperability | ocl_media_sdk_interop Shows how to use Intel Media SDK and Intel? SDK for Open CL? applications together for efficient video decoding and fast post-processing. |
HEVC GPU Assist APIs | sample_h265_gaa Supplies examples of the typical data and control flow for using HEVC GPU Assist APIs effectively. |
注:本文的代码基于 Intel_Media_SDK_2017_R1。
Intel MSDK encoding sample
以下是我改编过的 encoding sample 用法,利用 FFmpeg 进行 mux:
>intel_msdk_enc.exe
Intel(R) Media SDK Encoding Sample Version 3.5.915.45327
Usage: intel_msdk_enc.exe h264|mpeg2 [Options] -i input_yuv_file -o output_encoded_file -w width -h height
Options:
[-f frameRate] - video frame rate (frames per second)
[-b bitRate] - encoded bit rate (Kbits per second)
[-u speed|quality|balanced] - target usage
[-hw] - use platform specific SDK implementation, if not specified software implementation is used
[-d3d] - work with d3d surfaces
[-d3d11] - work with d3d11 surfaces
Intel MSDK encoding 代码
以下是整个编码及写入文件过程的概要代码,略去各个函数的具体实现和资源释放:
CSmplYUVReader g_file_reader;
ffmpeg_writer g_file_writer;
CEncodingPipeline enc_pipeline;
sInputParams Params = {
}; // input parameters from command line
mfxStatus sts = ParseInputString( argv, (mfxU8)argc, &Params );
std::vector<msdk_char*> srcFileBuff;
sts = g_file_reader.Init( Params.strSrcFile, Params.ColorFormat, 1, srcFileBuff );
sts = enc_pipeline.Init( &Params, feed_surface, on_encoded_pkt );
mfxExtCodingOptionSPSPPS sps_pps = enc_pipeline.GetSPSPPS();
sts = g_file_writer.Init( &Params, sps_pps.SPSBuffer, sps_pps.SPSBufSize,
sps_pps.PPSBuffer, sps_pps.PPSBufSize );
while (true) {
sts = enc_pipeline.Run();
if (MFX_ERR_DEVICE_LOST == sts || MFX_ERR_DEVICE_FAILED == sts) {
sts = enc_pipeline.ResetDevice();
sts = enc_pipeline.ResetMFXComponents(&Params);
continue;
}
else
break;
}
enc_pipeline.Close();
g_file_writer.Close();
CEncodingPipeline::Init 函数
初始化 MSDK 编码用的 pipeline。
mfxStatus CEncodingPipeline::Init(sInputParams *pParams, PF_FEED_SURFACE pfFeedSurface, PF_ON_ENCODED_PKT pfEncodePktCb)
{
mfxStatus sts = MFX_ERR_NONE;
m_feedSurfaceCb = pfFeedSurface;
m_onEncPktCb = pfEncodePktCb;
mfxVersion version;
version.Major = 1;
version.Minor = 0;
if (pParams->bUseHWLib