8323
- 收藏
- 点赞
- 分享
- 举报
Hi3515视频解码问题
原意是使用ffmpeg抽取一个avi文件里面的视频流,将该视频流存文件,然后将该文件替换掉sdk demo程序里面的sample_d1.h264,执行demo程序,倒是没报错,但是视频就是出不来,错误信息如下:
----------------------------------------------------------------Hi515运行时错误信息----------------------------------------------------------------------------
Version: [Hi3515_MPP_V1.0.2.0 Debug], Build Time[Mar 26 2010, 10:13:19]
------- Perf(us) -------
ID Parse HWdec SWdec SWint HWrprY SWrprY SWintY HWrprC SWrprC SWintC
0 14 0 0 0 0 0 0 0 0 0
------- Const -------
ID W H AlignW AlignH Ref DispQue RmvQue SendQue DescBuf
0 720 576 720 576 16 1919 1983 63 207232
------- Status -------
ID W H Ref DispQue RmvQue SendQue DescBuf Out Pic 10Fld State Slot
0 0 0 0 0 0 0 0 1 0 0 0 0
------ HW Stat -------
ID Start Eop Empty StartY IntY StartC IntC
0 0 0 0 0 0 0 0
------- Err Stat -------
ID ErrNalu LostPic ErrSlc LostSlc Overlap ErrW ErrH ErrRef ErrCncl ErrBigF
0 21688 0 0 0 0 0 0 0 0 0
------- Flow Stat -------
ID RecvPic DecPic SendPic RecvAUD RlsAud RecvEOS NoFB Rst pps fps
0 0 0 0 0 0 0 0 0 0 0
抽取h264视频流的代码
----------------------------------------------------------------------------------x86抽取视频流代码-------------------------------------------------------------------------------------
#include
#include
#include
#include
int main(int argc,char ** argv)
{
AVFormatContext * fmt_ctx = NULL;
AVPacket pkt;
char * file_name = NULL;
char * out_file = NULL;
int ret = -1;
int video_stream_idx = -1;
int count = 0;
FILE * fp = NULL;
int Mb = 0;
if(argc != 3)
{
printf("need 2 param.\n");
return -1;
}
file_name = argv[1];
out_file = argv[2];
av_register_all();
ret = avformat_open_input(&fmt_ctx,file_name,NULL,NULL);
if(ret < 0)
{
printf("open input file failed,exit.\n");
return ret;
}
printf("^^^^^^^^^^^Format :%s ^^^^^^^^^^^^^\n", fmt_ctx->iformat->name);
ret = avformat_find_stream_info(fmt_ctx,NULL);
if(ret < 0)
{
printf("find stream failed,exit.\n");
return ret;
}
ret = av_find_best_stream(fmt_ctx,AVMEDIA_TYPE_VIDEO,-1,-1,NULL,0);
if(ret < 0)
{
printf("find best stream failed,exit.\n");
return ret;
}
video_stream_idx = ret;
printf("video encode type:%d\n",fmt_ctx->streams[video_stream_idx]->codec->codec_id);
AVCodecContext* code_ctx = fmt_ctx->streams[video_stream_idx]->codec;
printf("image size width:%d\theight:%d\tpix format:%d",code_ctx->width,code_ctx->height,code_ctx->pix_fmt);
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
printf("press \'q\' to exit\n""press \'c\' to continue\n");
#if 1
if(getchar() == 'q')
{
goto exit;
}
fp = fopen(out_file,"w+");
if(NULL == fp)
{
printf("open file %s failed.\n",out_file);
}
else
{
while(av_read_frame(fmt_ctx,&pkt) >= 0)
{
if(pkt.size == 0)
break;
if(pkt.stream_index != video_stream_idx)
{
av_free_packet(&pkt);
continue;
}
count+=pkt.size;
if(count/(1024*1024) != Mb) //打印进度,不用关心
{
Mb = count/(1024*1024);
if(Mb%10 == 0 )
printf("\n");
printf("#");
}
if(1 != fwrite(pkt.data,pkt.size,1,fp))
{
printf("write file failed.\n");
break;
}
//printf("read packet size:%d\tcount:%d\n",pkt.size,count);
av_free_packet(&pkt);
}
}
fclose(fp);
#endif
exit:
avformat_close_input(&fmt_ctx);
return 0;
}
编译通过后执行,打印如下:
[root@localhost demuxing]# ./demuxing /work/VM_SHARE/swap/test80m.avi /ext_disk/Hi3515_work/Bin/xxoo.h264
^^^^^^^^^^^Format :avi ^^^^^^^^^^^^^
video encode type:28
image size width:720 height:544 pix format:0press 'q' to exit
press 'c' to continue
打印说明:
^^^^^^^^^^^Format :avi ^^^^^^^^^^^^^ 说明输入文件是avi文件
video encode type:28 我查了下codec_id :28正好是AV_CODEC_ID_H264,表明是h264视频流
之后就是视频的尺寸,像素格式了,像素格式查了下,0代表的是 PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
这上面就是视频的一些属性,与sdk demo程序里面唯一不同的就是视频尺寸的宽度
这是sdk demo里面解码器的配置
stH264Attr.u32PicHeight = 576;
stH264Attr.u32PicWidth = 720;
stH264Attr.u32RefFrameNum = 2;
stH264Attr.enMode = H264D_MODE_STREAM;
希望熟悉视频编解码的朋友指点一二,不胜感激……
----------------------------------------------------------------Hi515运行时错误信息----------------------------------------------------------------------------
Version: [Hi3515_MPP_V1.0.2.0 Debug], Build Time[Mar 26 2010, 10:13:19]
------- Perf(us) -------
ID Parse HWdec SWdec SWint HWrprY SWrprY SWintY HWrprC SWrprC SWintC
0 14 0 0 0 0 0 0 0 0 0
------- Const -------
ID W H AlignW AlignH Ref DispQue RmvQue SendQue DescBuf
0 720 576 720 576 16 1919 1983 63 207232
------- Status -------
ID W H Ref DispQue RmvQue SendQue DescBuf Out Pic 10Fld State Slot
0 0 0 0 0 0 0 0 1 0 0 0 0
------ HW Stat -------
ID Start Eop Empty StartY IntY StartC IntC
0 0 0 0 0 0 0 0
------- Err Stat -------
ID ErrNalu LostPic ErrSlc LostSlc Overlap ErrW ErrH ErrRef ErrCncl ErrBigF
0 21688 0 0 0 0 0 0 0 0 0
------- Flow Stat -------
ID RecvPic DecPic SendPic RecvAUD RlsAud RecvEOS NoFB Rst pps fps
0 0 0 0 0 0 0 0 0 0 0
抽取h264视频流的代码
----------------------------------------------------------------------------------x86抽取视频流代码-------------------------------------------------------------------------------------
#include
#include
#include
#include
int main(int argc,char ** argv)
{
AVFormatContext * fmt_ctx = NULL;
AVPacket pkt;
char * file_name = NULL;
char * out_file = NULL;
int ret = -1;
int video_stream_idx = -1;
int count = 0;
FILE * fp = NULL;
int Mb = 0;
if(argc != 3)
{
printf("need 2 param.\n");
return -1;
}
file_name = argv[1];
out_file = argv[2];
av_register_all();
ret = avformat_open_input(&fmt_ctx,file_name,NULL,NULL);
if(ret < 0)
{
printf("open input file failed,exit.\n");
return ret;
}
printf("^^^^^^^^^^^Format :%s ^^^^^^^^^^^^^\n", fmt_ctx->iformat->name);
ret = avformat_find_stream_info(fmt_ctx,NULL);
if(ret < 0)
{
printf("find stream failed,exit.\n");
return ret;
}
ret = av_find_best_stream(fmt_ctx,AVMEDIA_TYPE_VIDEO,-1,-1,NULL,0);
if(ret < 0)
{
printf("find best stream failed,exit.\n");
return ret;
}
video_stream_idx = ret;
printf("video encode type:%d\n",fmt_ctx->streams[video_stream_idx]->codec->codec_id);
AVCodecContext* code_ctx = fmt_ctx->streams[video_stream_idx]->codec;
printf("image size width:%d\theight:%d\tpix format:%d",code_ctx->width,code_ctx->height,code_ctx->pix_fmt);
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
printf("press \'q\' to exit\n""press \'c\' to continue\n");
#if 1
if(getchar() == 'q')
{
goto exit;
}
fp = fopen(out_file,"w+");
if(NULL == fp)
{
printf("open file %s failed.\n",out_file);
}
else
{
while(av_read_frame(fmt_ctx,&pkt) >= 0)
{
if(pkt.size == 0)
break;
if(pkt.stream_index != video_stream_idx)
{
av_free_packet(&pkt);
continue;
}
count+=pkt.size;
if(count/(1024*1024) != Mb) //打印进度,不用关心
{
Mb = count/(1024*1024);
if(Mb%10 == 0 )
printf("\n");
printf("#");
}
if(1 != fwrite(pkt.data,pkt.size,1,fp))
{
printf("write file failed.\n");
break;
}
//printf("read packet size:%d\tcount:%d\n",pkt.size,count);
av_free_packet(&pkt);
}
}
fclose(fp);
#endif
exit:
avformat_close_input(&fmt_ctx);
return 0;
}
编译通过后执行,打印如下:
[root@localhost demuxing]# ./demuxing /work/VM_SHARE/swap/test80m.avi /ext_disk/Hi3515_work/Bin/xxoo.h264
^^^^^^^^^^^Format :avi ^^^^^^^^^^^^^
video encode type:28
image size width:720 height:544 pix format:0press 'q' to exit
press 'c' to continue
打印说明:
^^^^^^^^^^^Format :avi ^^^^^^^^^^^^^ 说明输入文件是avi文件
video encode type:28 我查了下codec_id :28正好是AV_CODEC_ID_H264,表明是h264视频流
之后就是视频的尺寸,像素格式了,像素格式查了下,0代表的是 PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
这上面就是视频的一些属性,与sdk demo程序里面唯一不同的就是视频尺寸的宽度
这是sdk demo里面解码器的配置
stH264Attr.u32PicHeight = 576;
stH264Attr.u32PicWidth = 720;
stH264Attr.u32RefFrameNum = 2;
stH264Attr.enMode = H264D_MODE_STREAM;
希望熟悉视频编解码的朋友指点一二,不胜感激……
我来回答
回答12个
时间排序
认可量排序
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2015-11-23 14:01:50
-
2014-04-16 11:53:29
-
2013-08-05 09:26:42
-
02014-06-24 15:15:46
-
2014-10-14 09:17:06
-
2014-10-24 09:41:52
-
2013-11-27 15:32:20
-
2012-12-04 11:41:16
-
2014-12-09 08:59:38
-
2014-09-21 15:42:00
-
2014-06-19 17:51:35
-
2013-06-23 13:04:25
-
2012-11-25 12:53:19
-
132013-06-23 12:21:29
-
2013-11-29 09:42:11
-
2014-04-18 10:47:48
-
2014-03-27 10:29:53
-
2013-05-18 19:29:05
-
2014-10-24 19:25:36
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
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
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认