openH264编码流程
来源:互联网 发布:六十甲子单双计算法 编辑:程序博客网 时间:2024/06/05 23:06
openH264编码流程
之前在项目中用过openH264进行h264编码,本文介绍一下编码流程,算是做一个总结。
编码流程基本可以分为3步:
1.创建编码器。
int result = WelsCreateSVCEncoder(&encoder);
可以通过返回的参数是否为cmResultSuccess来判断编码器是否创建成功。
2.初始化编码器,包括各种参数的设置。
memset(&encParam, 0, sizeof(SEncParamExt));encoder->GetDefaultParams(&encParam);encParam.iUsageType = CAMERA_VIDEO_REAL_TIME;encParam.fMaxFrameRate = fps;encParam.iPicWidth = videoWidth;encParam.iPicHeight = videoHeight;encParam.iTargetBitrate = bitrate;encParam.iRCMode = RC_QUALITY_MODE;encParam.iTemporalLayerNum = 1;encParam.iSpatialLayerNum = 1;encParam.bEnableDenoise = false;encParam.bEnableBackgroundDetection = true;encParam.bEnableAdaptiveQuant = false;encParam.bEnableFrameSkip = false;encParam.bEnableLongTermReference = false;encParam.uiIntraPeriod = gop;encParam.eSpsPpsIdStrategy = CONSTANT_ID;encParam.bPrefixNalAddingCtrl = false;encParam.sSpatialLayers[0].iVideoWidth = videoWidth;encParam.sSpatialLayers[0].iVideoHeight = videoHeight;encParam.sSpatialLayers[0].fFrameRate = fps;encParam.sSpatialLayers[0].iSpatialBitrate = bitrate;encParam.sSpatialLayers[0].iMaxSpatialBitrate = encParam.iMaxBitrate;encoder->InitializeExt (&encParam);
在配置参数是,使用了SEncParamExt来进行配置,如果不需要配置这么多的参数的话,也可以使用SEncParamBase来进行配置。
3.调用编码器开始编码。
memset (&info, 0, sizeof (SFrameBSInfo));SSourcePicture pic;memset (&pic, 0, sizeof (SSourcePicture));pic.iPicWidth = encParam.iPicWidth;pic.iPicHeight = encParam.iPicHeight;pic.iColorFormat = videoFormatI420;pic.iStride[0] = pic.iPicWidth;pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1;pic.pData[0] = i420_scaled_frame.y;pic.pData[1] = i420_scaled_frame.u;pic.pData[2] = i420_scaled_frame.v;int rv = encoder->EncodeFrame (&pic, &info);
因为编码接收的数据为YUV420P格式的,所以如果视频数据不是这种格式的话就需要转换一下格式,然后将数据赋值给pic,然后就完成了编码。编码后的数据是保存在info中的,取数据的时候要注意需循环读取。
0 0
- openH264编码流程
- openH264解码流程
- OpenH264
- openh264使用指南
- openh264限制slice/nal分片大小导致的编码数据错误
- Openh264编译小记
- Webrtc Intro - OpenH264 Integrate
- openH264 1.6下安卓编译
- VS2012编译openh264 1.6
- openH264参数总结
- X264编码流程详解
- OpenCL编码流程
- Stagefright的编码流程
- HEVC编码流程解读
- X264编码流程详解
- X264编码流程详解
- x264编码流程分析
- HEVC编码流程解读
- 第三方开源库:个推
- 关于C++域作用符详解
- 在Ubuntu 16.04 LTS 下用Vim 打造自己的Python IDE 问题总结
- Android中dp px sp之间转化
- Gradle笔记2-构建脚本
- openH264编码流程
- 手机视频直播系统开发技术难点分析
- 告别Spinner下拉列表,用popupWindow 更美好
- linux下的编程问题
- bat-1
- 通讯录的获取
- android-async-http-master这个开源框架 post请求头怎么设置
- 关于Linux中创建软连接ln -s出现红色闪烁文件名
- Android scrollTo() scrollBy() Scroller讲解及应用