6558
- 收藏
- 点赞
- 分享
- 举报
【已解决】Hi3798M esplay
本帖最后由 yang1372073 于 2017-1-19 09:02 编辑
HI3798M 本地播放h265 ES 文件没有异常
但是Hi3798M接网络流实时播放,延时会短时间内累计,会从几百ms增加至5min左右,
1-文件播放
while (!g_StopThread)
{
if (g_bVidPlay)
{
if (HI_FALSE != g_bReadFrameSize)
{
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, 0x100000, &StreamBuf, 0);
}
else
{
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, 0x4000, &StreamBuf, 0);
}
if (HI_SUCCESS == Ret)
{
bVidBufAvail = HI_TRUE;
if (HI_FALSE != g_bReadFrameSize)
{
Readlen = fread(&FrameSize, 1, 4, g_pVidEsFile);
if (Readlen == 4)
{}
else
{
FrameSize = 0x4000;
}
}
else
{
FrameSize = 0x4000;
}
Readlen = fread(StreamBuf.pu8Data, sizeof(HI_S8), FrameSize, g_pVidEsFile);
if (Readlen > 0)
{
Ret = HI_UNF_AVPLAY_PutBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, Readlen, 0);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_PutBuf failed.\n");
}
FrameSize = 0;
}
else if (Readlen == 0)
{
if (HI_TRUE == g_PlayOnce)
{
HI_BOOL bIsEmpty = HI_FALSE;
HI_UNF_AVPLAY_FLUSH_STREAM_OPT_S stFlushOpt;
sample_printf("Esplay flush stream.\n");
HI_UNF_AVPLAY_FlushStream(hAvplay, &stFlushOpt);
do {
Ret = HI_UNF_AVPLAY_IsBuffEmpty(hAvplay, &bIsEmpty);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_IsBuffEmpty failed.\n");
break;
}
}while(bIsEmpty != HI_TRUE);
sleep(5);
sample_printf("Finish, esplay exit!\n");
exit(0);
}
else
{
sample_printf("read vid file end and rewind!\n");
rewind(g_pVidEsFile);
}
}
else
{
perror("read vid file error\n");
}
}
else
{
bVidBufAvail = HI_FALSE;
}
}
if (g_bAudPlay)
{
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_AUD, 0x1000, &StreamBuf, 0);
if (HI_SUCCESS == Ret)
{
bAudBufAvail = HI_TRUE;
Readlen = fread(StreamBuf.pu8Data, sizeof(HI_S8), 0x1000, g_pAudEsFile);
if (Readlen > 0)
{
counter++;
Ret = HI_UNF_AVPLAY_PutBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_AUD, Readlen, 0);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_PutBuf failed.\n");
}
}
else if (Readlen == 0)
{
sample_printf("read aud file end and rewind!\n");
rewind(g_pAudEsFile);
if (g_AudEsFileOffest)
{
fseek(g_pAudEsFile, g_AudEsFileOffest, SEEK_SET);
}
}
else
{
perror("read aud file error\n");
}
}
else if (Ret != HI_SUCCESS)
{
bAudBufAvail = HI_FALSE;
}
}
/* wait for buffer */
if ((HI_FALSE == bAudBufAvail) && (HI_FALSE == bVidBufAvail))
{
usleep(1000 * 10);
}
}
2-实时播放
while (!g_StopThread)
{
#ifdef TIME_PRINT
gettimeofday(&startTime,NULL);
#endif
ret_len = airrx_read(tsbuf, 188);
Readlen = TsDemux(tsbuf, ret_len, ts_header, pat_header, pmt_header, ts_pes, bitstream, &bitstream_type);
if(Readlen <= 0)
continue;
if (g_bVidPlay && ((bitstream_type==H264)||(bitstream_type==H265))) //video
{
memcpy(video_buf, *bitstream, sizeof(unsigned char)*Readlen);
video_buf += Readlen;
i += Readlen;
if(i <= 0x80)
continue;
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, i, &StreamBuf, 0);
if (HI_SUCCESS == Ret)
{
bVidBufAvail = HI_TRUE;
video_buf = video_buf - i;
memcpy(StreamBuf.pu8Data, video_buf, sizeof(unsigned char)*i);
if(0)
{
static FILE *f;
static int flag;
if (!flag)
{
f = fopen("video.h265","wb");
flag = 1;
}
fwrite(StreamBuf.pu8Data, 1, i,f);
}
if (i > 0)
{
Ret = HI_UNF_AVPLAY_PutBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, i, -1);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_PutBuf failed.\n");
}
#ifdef TIME_PRINT
gettimeofday(&endTime, NULL);
Timeuse = 1000000*(endTime.tv_sec - startTime.tv_sec) + (endTime.tv_usec - startTime.tv_usec);
printf("Timeuse = %f\n", Timeuse);
#endif
i = 0;
}
else if (i == 0)
{
}
else
{
perror("read vid file error\n");
}
}
else
{
bVidBufAvail = HI_FALSE;
}
}
if (g_bAudPlay && (bitstream_type==AAC)) //audio
{
memcpy(audio_buf, *bitstream, sizeof(unsigned char)*Readlen);
audio_buf += Readlen;
j += Readlen;
if(j <= 0x20)
continue;
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_AUD, j, &StreamBuf, 0);
if (HI_SUCCESS == Ret)
{
bAudBufAvail = HI_TRUE;
audio_buf = audio_buf - j;
memcpy(StreamBuf.pu8Data, audio_buf, sizeof(unsigned char)*j);
if (j > 0)
{
Ret = HI_UNF_AVPLAY_PutBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_AUD, j, -1);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_PutBuf failed.\n");
}
j = 0;
}
else if (j == 0)
{
sample_printf("read aud file end and rewind!\n");
}
else
{
perror("read aud file error\n");
}
}
else if (Ret != HI_SUCCESS)
{
bAudBufAvail = HI_FALSE;
}
}
/* wait for buffer */
if ((HI_FALSE == bAudBufAvail) && (HI_FALSE == bVidBufAvail))
{
usleep(1000 * 10);
}
}
HI3798M 本地播放h265 ES 文件没有异常
但是Hi3798M接网络流实时播放,延时会短时间内累计,会从几百ms增加至5min左右,
1-文件播放
while (!g_StopThread)
{
if (g_bVidPlay)
{
if (HI_FALSE != g_bReadFrameSize)
{
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, 0x100000, &StreamBuf, 0);
}
else
{
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, 0x4000, &StreamBuf, 0);
}
if (HI_SUCCESS == Ret)
{
bVidBufAvail = HI_TRUE;
if (HI_FALSE != g_bReadFrameSize)
{
Readlen = fread(&FrameSize, 1, 4, g_pVidEsFile);
if (Readlen == 4)
{}
else
{
FrameSize = 0x4000;
}
}
else
{
FrameSize = 0x4000;
}
Readlen = fread(StreamBuf.pu8Data, sizeof(HI_S8), FrameSize, g_pVidEsFile);
if (Readlen > 0)
{
Ret = HI_UNF_AVPLAY_PutBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, Readlen, 0);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_PutBuf failed.\n");
}
FrameSize = 0;
}
else if (Readlen == 0)
{
if (HI_TRUE == g_PlayOnce)
{
HI_BOOL bIsEmpty = HI_FALSE;
HI_UNF_AVPLAY_FLUSH_STREAM_OPT_S stFlushOpt;
sample_printf("Esplay flush stream.\n");
HI_UNF_AVPLAY_FlushStream(hAvplay, &stFlushOpt);
do {
Ret = HI_UNF_AVPLAY_IsBuffEmpty(hAvplay, &bIsEmpty);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_IsBuffEmpty failed.\n");
break;
}
}while(bIsEmpty != HI_TRUE);
sleep(5);
sample_printf("Finish, esplay exit!\n");
exit(0);
}
else
{
sample_printf("read vid file end and rewind!\n");
rewind(g_pVidEsFile);
}
}
else
{
perror("read vid file error\n");
}
}
else
{
bVidBufAvail = HI_FALSE;
}
}
if (g_bAudPlay)
{
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_AUD, 0x1000, &StreamBuf, 0);
if (HI_SUCCESS == Ret)
{
bAudBufAvail = HI_TRUE;
Readlen = fread(StreamBuf.pu8Data, sizeof(HI_S8), 0x1000, g_pAudEsFile);
if (Readlen > 0)
{
counter++;
Ret = HI_UNF_AVPLAY_PutBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_AUD, Readlen, 0);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_PutBuf failed.\n");
}
}
else if (Readlen == 0)
{
sample_printf("read aud file end and rewind!\n");
rewind(g_pAudEsFile);
if (g_AudEsFileOffest)
{
fseek(g_pAudEsFile, g_AudEsFileOffest, SEEK_SET);
}
}
else
{
perror("read aud file error\n");
}
}
else if (Ret != HI_SUCCESS)
{
bAudBufAvail = HI_FALSE;
}
}
/* wait for buffer */
if ((HI_FALSE == bAudBufAvail) && (HI_FALSE == bVidBufAvail))
{
usleep(1000 * 10);
}
}
2-实时播放
while (!g_StopThread)
{
#ifdef TIME_PRINT
gettimeofday(&startTime,NULL);
#endif
ret_len = airrx_read(tsbuf, 188);
Readlen = TsDemux(tsbuf, ret_len, ts_header, pat_header, pmt_header, ts_pes, bitstream, &bitstream_type);
if(Readlen <= 0)
continue;
if (g_bVidPlay && ((bitstream_type==H264)||(bitstream_type==H265))) //video
{
memcpy(video_buf, *bitstream, sizeof(unsigned char)*Readlen);
video_buf += Readlen;
i += Readlen;
if(i <= 0x80)
continue;
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, i, &StreamBuf, 0);
if (HI_SUCCESS == Ret)
{
bVidBufAvail = HI_TRUE;
video_buf = video_buf - i;
memcpy(StreamBuf.pu8Data, video_buf, sizeof(unsigned char)*i);
if(0)
{
static FILE *f;
static int flag;
if (!flag)
{
f = fopen("video.h265","wb");
flag = 1;
}
fwrite(StreamBuf.pu8Data, 1, i,f);
}
if (i > 0)
{
Ret = HI_UNF_AVPLAY_PutBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_VID, i, -1);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_PutBuf failed.\n");
}
#ifdef TIME_PRINT
gettimeofday(&endTime, NULL);
Timeuse = 1000000*(endTime.tv_sec - startTime.tv_sec) + (endTime.tv_usec - startTime.tv_usec);
printf("Timeuse = %f\n", Timeuse);
#endif
i = 0;
}
else if (i == 0)
{
}
else
{
perror("read vid file error\n");
}
}
else
{
bVidBufAvail = HI_FALSE;
}
}
if (g_bAudPlay && (bitstream_type==AAC)) //audio
{
memcpy(audio_buf, *bitstream, sizeof(unsigned char)*Readlen);
audio_buf += Readlen;
j += Readlen;
if(j <= 0x20)
continue;
Ret = HI_UNF_AVPLAY_GetBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_AUD, j, &StreamBuf, 0);
if (HI_SUCCESS == Ret)
{
bAudBufAvail = HI_TRUE;
audio_buf = audio_buf - j;
memcpy(StreamBuf.pu8Data, audio_buf, sizeof(unsigned char)*j);
if (j > 0)
{
Ret = HI_UNF_AVPLAY_PutBuf(hAvplay, HI_UNF_AVPLAY_BUF_ID_ES_AUD, j, -1);
if (Ret != HI_SUCCESS)
{
sample_printf("call HI_UNF_AVPLAY_PutBuf failed.\n");
}
j = 0;
}
else if (j == 0)
{
sample_printf("read aud file end and rewind!\n");
}
else
{
perror("read aud file error\n");
}
}
else if (Ret != HI_SUCCESS)
{
bAudBufAvail = HI_FALSE;
}
}
/* wait for buffer */
if ((HI_FALSE == bAudBufAvail) && (HI_FALSE == bVidBufAvail))
{
usleep(1000 * 10);
}
}
我来回答
回答10个
时间排序
认可量排序
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2017-05-17 22:13:17
-
2017-02-21 08:42:35
-
2018-03-16 17:44:06
-
2016-09-08 17:32:23
-
2016-03-29 11:26:22
-
2016-03-30 17:23:47
-
2016-01-18 21:02:22
-
2018-05-17 18:57:50
-
2016-12-06 09:38:08
-
2017-09-04 18:27:17
-
2016-12-02 13:43:03
-
2016-04-08 16:38:30
-
2020-11-30 08:37:32
-
2017-04-21 12:08:27
-
2019-12-24 15:11:16
-
2018-06-04 20:48:43
-
2016-07-13 09:32:28
-
2016-07-13 18:10:40
-
2017-07-04 21:43:48
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5RK3588的DPHY0接lt6911uxe转HDMI抓帧分辨率不对
-
20求rv1106板子的sdk包或者开发板资料
-
10ss928烧录uboot失败
-
10求助,3588调试imx586和ov50c40时,按照瑞芯微的单摄8k配置好设备树后,驱动配置的8k分辨率的,但是只能抓到4k的图,且颜色偏粉
-
50帮忙解决个交叉编译的问题
-
20帮忙交叉编译个源码
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认