IS_PARAMETER_SET_NAL:是不是参数集nal
头文件codec_api.h codec_app_def.h codec_def.h codec_ver.h
SEncParamExt.iMultipleThreadIdc: lager than 1: count number of threads;
typedef enum {
CAMERA_VIDEO_REAL_TIME, ///< camera video for real-time communication
SCREEN_CONTENT_REAL_TIME, ///< screen content signal
CAMERA_VIDEO_NON_REAL_TIME,
SCREEN_CONTENT_NON_REAL_TIME,
INPUT_CONTENT_TYPE_ALL,
} EUsageType;
typedef enum {
SM_SINGLE_SLICE = 0, ///< | SliceNum==1
SM_FIXEDSLCNUM_SLICE = 1, ///< | according to SliceNum | enabled dynamic slicing for multi-thread
SM_RASTER_SLICE = 2, ///< | according to SlicesAssign | need input of MB numbers each slice. In addition, if other constraint in SSliceArgument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
SM_SIZELIMITED_SLICE = 3, ///< | according to SliceSize | slicing according to size, the slicing will be dynamic(have no idea about slice_nums until encoding current frame)
SM_RESERVED = 4
} SliceModeEnum;
Step1:setup encoder
ISVCEncoder* encoder_;
int rv = WelsCreateSVCEncoder (&encoder_);
assert (rv == 0);
assert (encoder_ != NULL);
step2:initilize with basic parameter
SEncParamBase param;
memset (&param, 0, sizeof (SEncParamBase));
param.iUsageType = usageType; //from EUsageType enum
param.fMaxFrameRate = frameRate;
param.iPicWidth = width;
param.iPicHeight = height;
param.iTargetBitrate = 5000000;
encoder_->Initialize (&param);
Step 2:initialize with extension parameter
SEncParamExt param;
encoder_->GetDefaultParams (&param);
param.iUsageType = usageType;
param.fMaxFrameRate = frameRate;
param.iPicWidth = width;
param.iPicHeight = height;
param.iTargetBitrate = 5000000;
param.bEnableDenoise = denoise;
param.iSpatialLayerNum = layers;
//SM_DYN_SLICE don't support multi-thread now
if (sliceMode != SM_SINGLE_SLICE && sliceMode != SM_DYN_SLICE)
param.iMultipleThreadIdc = 2;
for (int i = 0; i < param.iSpatialLayerNum; i++) {
param.sSpatialLayers[i].iVideoWidth = width >> (param.iSpatialLayerNum - 1 - i);
param.sSpatialLayers[i].iVideoHeight = height >> (param.iSpatialLayerNum - 1 - i);
param.sSpatialLayers[i].fFrameRate = frameRate;
param.sSpatialLayers[i].iSpatialBitrate = param.iTargetBitrate;
param.sSpatialLayers[i].sSliceCfg.uiSliceMode = sliceMode;
if (sliceMode == SM_DYN_SLICE) {
param.sSpatialLayers[i].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 600;
param.uiMaxNalSize = 1500;
}
}
param.iTargetBitrate *= param.iSpatialLayerNum;
encoder_->InitializeExt (&param);
int videoFormat = videoFormatI420;
encoder_->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat);
Step3:set option, set option during encoding process
encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &g_LevelSetting);
int videoFormat = videoFormatI420;
encoder_->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat);
//changing encoding param SEncParamBase param; //fill in instant param即时参数content encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, &param);
Step4: encode and store ouput bistream
int frameSize = width * height * 3 / 2;
BufferedData buf;
buf.SetLength (frameSize);
assert (buf.Length() == (size_t)frameSize);
SFrameBSInfo info;
memset (&info, 0, sizeof (SFrameBSInfo));
SSourcePicture pic;
memset (&pic, 0, sizeof (SsourcePicture));
pic.iPicWidth = width;
pic.iPicHeight = height;
pic.iColorFormat = videoFormatI420;
pic.iStride[0] = pic.iPicWidth;
pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1;
pic.pData[0] = buf.data();
pic.pData[1] = pic.pData[0] + width * height;
pic.pData[2] = pic.pData[1] + (width * height >> 2);
for(int num = 0;num<total_num;num++) {
//prepare input data
rv = encoder_->EncodeFrame (&pic, &info);
assert (rv == cmResultSuccess);
if (info.eFrameType != videoFrameTypeSkip) {
//output bitstream handling
}
}
Step5:teardown encoder
if (encoder_) {
encoder_->Uninitialize();
WelsDestroySVCEncoder (encoder_);
}

openh264 api 使用的更多相关文章

  1. OpenH264

    转自:http://blog.csdn.net/chinabinlang/article/details/41209053 目前最常用的264工程师x264: 最近有又有一个开源工程OpenH264, ...

  2. OpenH264编译ffmpeg android

    思科的 安装NASM git clone https://github.com/cisco/openh264.git Android Builds install android sdk and nd ...

  3. 干货来袭-整套完整安全的API接口解决方案

    在各种手机APP泛滥的现在,背后都有同样泛滥的API接口在支撑,其中鱼龙混杂,直接裸奔的WEB API大量存在,安全性令人堪优 在以前WEB API概念没有很普及的时候,都采用自已定义的接口和结构,对 ...

  4. 12306官方火车票Api接口

    2017,现在已进入春运期间,真的是一票难求,深有体会.各种购票抢票软件应运而生,也有购买加速包提高抢票几率,可以理解为变相的黄牛.对于技术人员,虽然写一个抢票软件还是比较难的,但是还是简单看看123 ...

  5. 几个有趣的WEB设备API(二)

    浏览器和设备之间还有很多有趣的接口, 1.屏幕朝向接口 浏览器有两种方法来监听屏幕朝向,看是横屏还是竖屏. (1)使用css媒体查询的方法 /* 竖屏 */ @media screen and (or ...

  6. html5 canvas常用api总结(三)--图像变换API

    canvas的图像变换api,可以帮助我们更加方便的绘画出一些酷炫的效果,也可以用来制作动画.接下来将总结一下canvas的变换方法,文末有一个例子来更加深刻的了解和利用这几个api. 1.画布旋转a ...

  7. JavaScript 对数据处理的5个API

    JavaScript对数据处理包括向上取整.向下取整.四舍五入.固定精度和固定长度5种方式,分别对应ceil,floor,round,toFixed,toPrecision等5个API,本文将对这5个 ...

  8. ES5对Array增强的9个API

    为了更方便的对Array进行操作,ES5规范在Array的原型上新增了9个方法,分别是forEach.filter.map.reduce.reduceRight.some.every.indexOf ...

  9. javascript的api设计原则

    前言 本篇博文来自一次公司内部的前端分享,从多个方面讨论了在设计接口时遵循的原则,总共包含了七个大块.系卤煮自己总结的一些经验和教训.本篇博文同时也参考了其他一些文章,相关地址会在后面贴出来.很难做到 ...

随机推荐

  1. 如何分析Java程序中的死锁

    使用下面方式:产生java的Thread Dump信息 windows平台上:ctrl+break 或者 ctrl+(fn+b)键 Linux平台上:kill -3 pid (查找程序进程id -&g ...

  2. Tomcat7启动报Error listenerStart错误

    问题 Tomcat7在启动时报错,详细信息如下: 十一月 23, 2013 7:21:58 下午 org.apache.catalina.core.StandardContext startInter ...

  3. hdu-2045 递归

    #include <cstdio> #include <iostream> using namespace std; long long a[55] = {0,3,6}; lo ...

  4. PostgreSQL 保存json,jsonb类型

    PostgresQL 字符串隐式转换JSON脚本: -- 隐式将varchar转换为json CREATE OR REPLACE FUNCTION json_in_varchar(varchar) R ...

  5. 使用ScriptEngineManager解析json

    使用ScriptEngineManager能够解析比較复杂的json串,应用比較方便,可是效率不敢说,由于这种方法相当于执行了一次js.会占资源, 代码例如以下: try { String mdski ...

  6. Word实用教程——五分钟教你如何在任意页开始添加页码

    最近在写一篇论文,但是在排版上遇到一点小问题,就是要加入页码,而且页码是从目录的下一页开始计数,于是我就在网上找如何在任意页添加页码.后来辗转终于搞定,真心觉得这一个小功能让微软做的如此的麻烦,真是活 ...

  7. .NET MVC+ EF+调用存储过程 多表联查以及VIEW列表显示

    直接上干活,至于网上的一大堆处理方式不予评论,做好自己的就是最好的,供大家不走弯路 1.view页面 <link href="~/Content/bootstrap.css" ...

  8. VS2012高亮显示当前行背景色的问题

    在VS2012中,如果你不幸用了三方主题,尤其是深色主题.比如http://studiostyl.es/schemes/son-of-obsidian ,那么你很可能发现当前行高亮的样式变成了这样: ...

  9. [Windows Azure] Windows Azure Execution Models

    Windows Azure Execution Models Windows Azure provides different execution models for running applica ...

  10. linux命令(35):diff命令

    diff 命令是 linux上非常重要的工具,用于比较文件的内容,特别是比较两个版本不同的文件以找到改动的地方.diff在命令行中打印每一个行的改动.最新版本的diff还支持二进制文件.diff程序的 ...