elvisup

elvisup

0个粉丝

17

问答

0

专栏

23

资料

elvisup  发布于  2016-07-12 21:01:32
采纳率 0%
17个问答
10158

在Hi3516中执行sample_venc出错

 
代码中在调用HI_MPI_VENC_GetStream之前使用一个select监听,但是老是等不到,总是超时:

/mnt/home # ./sample_venc 0
=============SAMPLE_COMM_VI_SetMipiAttr enWDRMode: 0
linear mode
-------OV4689 Sensor 1080P 60fps Linear Mode Initial OK!-------
         c) cbr.
         v) vbr.
         f) fixQp
please input choose rc mode!
c
please press twice ENTER to exit this sample
[SAMPLE_COMM_VENC_GetVencStreamProc]-1118: get venc stream time out, exit thread
[SAMPLE_COMM_VENC_GetVencStreamProc]-1118: get venc stream time out, exit thread
[SAMPLE_COMM_VENC_GetVencStreamProc]-1118: get venc stream time out, exit thread


请大家帮忙分析一下,代码如下:

[code]/******************************************************************************
* funciton : get stream from each channels and save them
******************************************************************************/
HI_VOID* SAMPLE_COMM_VENC_GetVencStreamProc(HI_VOID* p)
{
    HI_S32 i;
    HI_S32 s32ChnTotal;
    VENC_CHN_ATTR_S stVencChnAttr;
    SAMPLE_VENC_GETSTREAM_PARA_S* pstPara;
    HI_S32 maxfd = 0;
    struct timeval TimeoutVal;
    fd_set read_fds;
    HI_S32 VencFd[VENC_MAX_CHN_NUM];
    HI_CHAR aszFileName[VENC_MAX_CHN_NUM][FILE_NAME_LEN];
    FILE* pFile[VENC_MAX_CHN_NUM];
    char szFilePostfix[10];
    VENC_CHN_STAT_S stStat;
    VENC_STREAM_S stStream;
    HI_S32 s32Ret;
    VENC_CHN VencChn;
    PAYLOAD_TYPE_E enPayLoadType[VENC_MAX_CHN_NUM];

    pstPara = (SAMPLE_VENC_GETSTREAM_PARA_S*)p;
    s32ChnTotal = pstPara->s32Cnt;

    /******************************************
     step 1:  check & prepare save-file & venc-fd
    ******************************************/
    if (s32ChnTotal >= VENC_MAX_CHN_NUM)
    {
        SAMPLE_PRT("input count invaild\n");
        return NULL;
    }
    for (i = 0; i < s32ChnTotal; i++)
    {
        /* decide the stream file name, and open file to save stream */
        VencChn = i;
        s32Ret = HI_MPI_VENC_GetChnAttr(VencChn, &stVencChnAttr);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("HI_MPI_VENC_GetChnAttr chn[%d] failed with %#x!\n", \
                       VencChn, s32Ret);
            return NULL;
        }
        enPayLoadType = stVencChnAttr.stVeAttr.enType;

        s32Ret = SAMPLE_COMM_VENC_GetFilePostfix(enPayLoadType, szFilePostfix);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("SAMPLE_COMM_VENC_GetFilePostfix [%d] failed with %#x!\n", \
                       stVencChnAttr.stVeAttr.enType, s32Ret);
            return NULL;
        }
        snprintf(aszFileName, FILE_NAME_LEN, "stream_chn%d%s", i, szFilePostfix);
        pFile = fopen(aszFileName, "wb");
        if (!pFile)
        {
            SAMPLE_PRT("open file[%s] failed!\n",
                       aszFileName);
            return NULL;
        }

        /* Set Venc Fd. */
        VencFd = HI_MPI_VENC_GetFd(i);
        if (VencFd < 0)
        {
            SAMPLE_PRT("HI_MPI_VENC_GetFd failed with %#x!\n",
                       VencFd);
            return NULL;
        }
        if (maxfd <= VencFd)
        {
            maxfd = VencFd;
        }
    }

    /******************************************
     step 2:  Start to get streams of each channel.
    ******************************************/
    while (HI_TRUE == pstPara->bThreadStart)
    {
        FD_ZERO(&read_fds);
        for (i = 0; i < s32ChnTotal; i++)
        {
            FD_SET(VencFd, &read_fds);
        }

        TimeoutVal.tv_sec  = 2;
        TimeoutVal.tv_usec = 0;
        s32Ret = select(maxfd + 1, &read_fds, NULL, NULL, &TimeoutVal);
        if (s32Ret < 0)
        {
            SAMPLE_PRT("select failed!\n");
            break;
        }
        else if (s32Ret == 0)
        {
            SAMPLE_PRT("get venc stream time out, exit thread\n");
            continue;
        }
        else
        {
            for (i = 0; i < s32ChnTotal; i++)
            {
                if (FD_ISSET(VencFd, &read_fds))
                {
                    /*******************************************************
                     step 2.1 : query how many packs in one-frame stream.
                    *******************************************************/
                    memset(&stStream, 0, sizeof(stStream));
                    s32Ret = HI_MPI_VENC_Query(i, &stStat);
                    if (HI_SUCCESS != s32Ret)
                    {
                        SAMPLE_PRT("HI_MPI_VENC_Query chn[%d] failed with %#x!\n", i, s32Ret);
                        break;
                    }
                                       
                                        /*******************************************************
                                         step 2.2 :suggest to check both u32CurPacks and u32LeftStreamFrames at the same time,for example:
                                         if(0 == stStat.u32CurPacks || 0 == stStat.u32LeftStreamFrames)
                                         {
                                                SAMPLE_PRT("NOTE: Current  frame is NULL!\n");
                                                continue;
                                         }
                                        *******************************************************/
                                        if(0 == stStat.u32CurPacks)
                                        {
                                                  SAMPLE_PRT("NOTE: Current  frame is NULL!\n");
                                                  continue;
                                        }
                    /*******************************************************
                     step 2.3 : malloc corresponding number of pack nodes.
                    *******************************************************/
                    stStream.pstPack = (VENC_PACK_S*)malloc(sizeof(VENC_PACK_S) * stStat.u32CurPacks);
                    if (NULL == stStream.pstPack)
                    {
                        SAMPLE_PRT("malloc stream pack failed!\n");
                        break;
                    }

                    /*******************************************************
                     step 2.4 : call mpi to get one-frame stream
                    *******************************************************/
                    stStream.u32PackCount = stStat.u32CurPacks;
                    s32Ret = HI_MPI_VENC_GetStream(i, &stStream, HI_TRUE);
                    if (HI_SUCCESS != s32Ret)
                    {
                        free(stStream.pstPack);
                        stStream.pstPack = NULL;
                        SAMPLE_PRT("HI_MPI_VENC_GetStream failed with %#x!\n", \
                                   s32Ret);
                        break;
                    }

                    /*******************************************************
                     step 2.5 : save frame to file
                    *******************************************************/
                    s32Ret = SAMPLE_COMM_VENC_SaveStream(enPayLoadType, pFile, &stStream);
                    if (HI_SUCCESS != s32Ret)
                    {
                        free(stStream.pstPack);
                        stStream.pstPack = NULL;
                        SAMPLE_PRT("save stream failed!\n");
                        break;
                    }
                    /*******************************************************
                     step 2.6 : release stream
                    *******************************************************/
                    s32Ret = HI_MPI_VENC_ReleaseStream(i, &stStream);
                    if (HI_SUCCESS != s32Ret)
                    {
                        free(stStream.pstPack);
                        stStream.pstPack = NULL;
                        break;
                    }
                    /*******************************************************
                     step 2.7 : free pack nodes
                    *******************************************************/
                    free(stStream.pstPack);
                    stStream.pstPack = NULL;
                }
            }
        }
    }

    /*******************************************************
    * step 3 : close save-file
    *******************************************************/
    for (i = 0; i < s32ChnTotal; i++)
    {
        fclose(pFile);
    }

    return NULL;
}
[/code]
我来回答
回答6个
时间排序
认可量排序

ngswfx

1个粉丝

55

问答

1

专栏

40

资料

ngswfx 2016-07-12 21:38:16
认可0
本帖最后由 ngswfx 于 2016-7-12 21:51 编辑

你这个线程 SAMPLE_COMM_VENC_GetVencStreamProc开启的时候,传递进来的参数结构具体值是多少。

主要要确定s32ChnTotal = pstPara->s32Cnt;的值。

进而定位maxfd 的值,你可以把这些值都printf出来,找原因。


////////我看了一下sample代码,你发的这个就是sample_comm_venc.c里面的一个线程,我估计你应该没修改过吧,这么看来应该问题没在sample层面。

/////什么开发板子,用的什么cmos,驱动装载情况log都说一下.

yangcanx

0个粉丝

8

问答

0

专栏

0

资料

yangcanx 2016-07-13 11:42:35
认可0
我的也有这个情况,求大神解决,楼主先看VI有没有中断吧。

default

0个粉丝

40

问答

0

专栏

0

资料

default 2016-07-13 13:45:23
认可1
是否没有视频数据,使用mpp/tools/下的vi_dump抓一下

elvisup

0个粉丝

17

问答

0

专栏

23

资料

elvisup 2016-07-13 14:04:13
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=33875&ptid=11923]default 发表于 2016-7-13 13:45[/url]
是否没有视频数据,使用mpp/tools/下的vi_dump抓一下[/quote]

用vi_dump出错:

/mnt/home # ./vi_dump 0 5

NOTICE: This tool only can be used for TESTING !!!
Usage: ./vi_dump [ViChn] [FrmCnt]. sample: ./vi_dump 0 5

HI_MPI_VI_SetFrameDepth err, vi chn 0 ,ret = 0xa0108010

说是系统没有初始化!

yangjking

0个粉丝

8

问答

0

专栏

2

资料

yangjking 2016-12-08 15:12:33
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=33880&ptid=11923]elvisup 发表于 2016-7-13 14:04[/url]
用vi_dump出错:

/mnt/home # ./vi_dump 0 5
[/quote]

lz,
您这问题解决了吗?我跟你报一样的错误。我的是3516a+imx185

qn1540523310

0个粉丝

1

问答

0

专栏

0

资料

qn1540523310 2018-11-08 14:58:38
认可0
我想问下我用的是hi.3516av200芯片+imx274的板子运行sample_venc文件时出现视频延迟,同时mipi打印信息是有的,但是没有vi打印信息,请问这种问题应该怎么修改。
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区