hi3516ev200进行rtmp推流报错"[SAMPLE_COMM_VENC_GetVencStreamProc]-2024: get venc stream time out, exit thr"
现象描述
如下图所示我在运行rtmp推流程序之后显示提示获取视频流失败,导致线程退出,而上面的提示又是"[Func]:imx307_2l_write_register [Line]:140 [Info]:I2C_WRITE error!",是与imx307相关的写寄存器错误,可能是sensor驱动相关的的错误,但是底层的sensor驱动时海思官方提供的时不可能错误的,所以可以联想到编译出程序所需sensor类型与我们开发板上的sensor类型不匹配,导致程序一系列与sensor相关的操作错误。
解决办法
在海思官方提供SDK的MPP/sample目录中有一个名为Makefile.param的sample编译脚本,其中的部分内容为:
################# select sensor type for your sample #################
#### SONY_IMX335_MIPI_5M_30FPS_12BIT #################
#### SONY_IMX335_MIPI_4M_30FPS_12BIT #################
#### SONY_IMX327_MIPI_2M_30FPS_12BIT #################
#### SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1 #################
#### SONY_IMX307_MIPI_2M_30FPS_12BIT #################
#### SONY_IMX307_MIPI_2M_30FPS_12BIT_WDR2TO1 #################
#### SONY_IMX335_MIPI_4M_30FPS_10BIT_WDR2TO1 #################
#### OMNIVISION_OS05A_MIPI_5M_30FPS_12BIT #################
#### BT1120_2M_30FPS_8BIT #################
#### the previous sequence only for Hi3516EV300,Hi3516DV200 etc. #####
#### BT656_2M_30FPS_8BIT #################
#### SONY_IMX307_2L_MIPI_2M_30FPS_12BIT #################
#### SONY_IMX307_2L_MIPI_2M_30FPS_12BIT_WDR2TO1 #################
#### SONY_IMX327_2L_MIPI_2M_30FPS_12BIT #################
#### SONY_IMX327_2L_MIPI_2M_30FPS_12BIT_WDR2TO1 #################
#### SMART_SC4236_MIPI_3M_30FPS_10BIT #################
#### SMART_SC4236_MIPI_3M_20FPS_10BIT #################
#### SMART_SC2235_DC_2M_30FPS_10BIT #################
#### SMART_SC2231_MIPI_2M_30FPS_10BIT #################
#### SMART_SC3235_MIPI_3M_30FPS_10BIT #################
#### GALAXYCORE_GC2053_MIPI_2M_30FPS_10BIT #################
#### GALAXYCORE_GC2053_MIPI_2M_30FPS_10BIT_FORCAR #################
SENSOR0_TYPE ?= SONY_IMX307_2L_MIPI_2M_30FPS_12BIT
上面提供了多种支持的sensor类型可供选择,其中最后一句:
SENSOR0_TYPE ?= SONY_IMX307_2L_MIPI_2M_30FPS_12BIT
是指定sensor类型为SONY_IMX307,要根据自己板载的sensor类型,从上面给出的sensor类型中做出相应的修改,我的开发板的sensor类型为SC3235,所以应该改为SENSOR0_TYPE ?= SMART_SC3235_MIPI_3M_30FPS_10BIT
我从海思的官方sdk中的sample_comm_vi.c文件中找到一个函数:
HI_VOID SAMPLE_COMM_VI_GetSensorInfo(SAMPLE_VI_CONFIG_S *pstViConfig)
{
HI_S32 i;
for (i = 0; i < VI_MAX_DEV_NUM; i++)
{
pstViConfig->astViInfo[i].stSnsInfo.s32SnsId = i;
pstViConfig->astViInfo[i].stSnsInfo.s32BusId = i;
pstViConfig->astViInfo[i].stSnsInfo.MipiDev = i;
hi_memset(&pstViConfig->astViInfo[i].stSnapInfo, sizeof(SAMPLE_SNAP_INFO_S), 0, sizeof(SAMPLE_SNAP_INFO_S));
pstViConfig->astViInfo[i].stPipeInfo.bMultiPipe = HI_FALSE;
pstViConfig->astViInfo[i].stPipeInfo.bVcNumCfged = HI_FALSE;
}
pstViConfig->astViInfo[0].stSnsInfo.enSnsType = SENSOR0_TYPE;
}
其中pstViConfig->astViInfo[0].stSnsInfo.enSnsType = SENSOR0_TYPE;
的SENSOR0_TYPE在程序中是没有定义的,是在刚刚我们上面看到的makefile中在程序编译的时候传入的sensor类型。同样在rtmp推流程序中也sample比较相似
在makefile文件中将原先指定的sensor类型改为-DSENSOR0_TYPE=SMART_SC3235_MIPI_3M_30FPS_10BIT
后重新执行make编译,将程序上传到开发板运行即可。当然出现[SAMPLE_COMM_VENC_GetVencStreamProc]-2024: get venc stream time out, exit thr"这个错误提示还可能是其他的原因,上面讲到的只是其中一种情况。