blacktulip7

blacktulip7

0个粉丝

3

问答

0

专栏

0

资料

blacktulip7  发布于  2013-08-12 18:50:59
采纳率 0%
3个问答
8144

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;

   希望熟悉视频编解码的朋友指点一二,不胜感激……
我来回答
回答12个
时间排序
认可量排序

sk-3

0个粉丝

6

问答

0

专栏

2

资料

sk-3 2013-08-12 20:28:37
认可0
你把一个avi 解码 抽出数据 然后保存成另一个文件,然后替换掉 sample下的.264?

然后运行sample ?

blacktulip7

0个粉丝

3

问答

0

专栏

0

资料

blacktulip7 2013-08-12 22:09:09
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=3573&ptid=1911]sk-3 发表于 2013-8-12 20:28[/url]
你把一个avi 解码 抽出数据 然后保存成另一个文件,然后替换掉 sample下的.264?

然后运行sample ?[/quote]

是的,不知道这种想法有没有问题

sk-3

0个粉丝

6

问答

0

专栏

2

资料

sk-3 2013-08-13 09:31:39
认可0
sample 只能解264的 编码的吧。你抽出.avi 不一定就是264的吧? avi也有好几种编码格式吧。
如果avi是 mpeg编码?,不知道为什么你要做这个转换? 表示疑问。本身你这个操作就很奇怪,可能我想不到你这么做的真实想法 :L

blacktulip7

0个粉丝

3

问答

0

专栏

0

资料

blacktulip7 2013-08-13 15:10:52
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=3575&ptid=1911]sk-3 发表于 2013-8-13 09:31[/url]
sample 只能解264的 编码的吧。你抽出.avi 不一定就是264的吧? avi也有好几种编码格式吧。
如果avi是 mpe ...[/quote]

avi封装的文件里面确实有mpeg4编码,之前这种情况我有碰到过,所以在前面我将码流的编码格式打印了出来,确定是264的,现在问题的大体方向基本找到,海思的解码器如果按流解码的话,需要往解码器里面投入NAL单元,ffmpeg里面通过av_read_freame获取出来的数据我看了下,不是解码器需要的NAL,

shuiguozhi

0个粉丝

0

问答

0

专栏

0

资料

shuiguozhi 2013-09-03 15:26:29
认可0
楼主,解决了没有!
不能解码的现象是什么?
我现在是拿的DEMO板,运行的 sample/sample_vdec 3
只要是用FFMPEG 编码出来的264文件放出来全是蓝屏。
编码器我换了XVID X264都一样的效果,甚至将stream_chn0.h264 用FFMPEG转码一次,都不行。
附带的文档中没有找到输入的说明。
ESEYE 264VISA根本看不出个所以然。希望交流一下,QQ 516393543

shuiguozhi

0个粉丝

0

问答

0

专栏

0

资料

shuiguozhi 2013-09-03 15:31:35
认可0
FFMPEG 的av_read_frame只是解复用 用的。
如果你确定你的AVI文件里的264数据正确的话,可以使用FFMPEG直接 -i input.avi -vcodec copy output.h264 这样就好了吧
我试过 -i stream_chn0.h264 -vcodec copy output.h264 输出的文件  是可以的!
所以可能是3531 对264编码有一定的要求,但是苦于没找到文档,所以如果你有什么有用的信息还请交流一下!

david

33个粉丝

368

问答

253

专栏

229

资料

david 2013-09-03 15:57:02
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=4191&ptid=1911]shuiguozhi 发表于 2013-9-3 15:31[/url]
FFMPEG 的av_read_frame只是解复用 用的。
如果你确定你的AVI文件里的264数据正确的话,可以使用FFMPEG直 ...[/quote]

其实你要确定的是AVI是否封装的264,甚至有的厂家会在264数据中添加进去自己的一些信息。

blacktulip7

0个粉丝

3

问答

0

专栏

0

资料

blacktulip7 2013-09-03 19:41:40
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=4191&ptid=1911]shuiguozhi 发表于 2013-9-3 15:31[/url]
FFMPEG 的av_read_frame只是解复用 用的。
如果你确定你的AVI文件里的264数据正确的话,可以使用FFMPEG直 ...[/quote]

楼主刚刚换工作,新工作有点忙,上面的问题一时半会还没空弄

david

33个粉丝

368

问答

253

专栏

229

资料

david 2013-09-03 21:53:25
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=4201&ptid=1911]blacktulip7 发表于 2013-9-3 19:41[/url]
楼主刚刚换工作,新工作有点忙,上面的问题一时半会还没空弄[/quote]

搞撒子去了。我也最近刚换工作。跟视频这块没啥大关系了。

shuiguozhi

0个粉丝

0

问答

0

专栏

0

资料

shuiguozhi 2013-09-05 09:49:34
认可0
那可真是痛苦,所有工具都用过了,找不出来区别。NALU_TOOL都用了。谁救救我哦

blacktulip7

0个粉丝

3

问答

0

专栏

0

资料

blacktulip7 2013-09-05 20:31:36
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=4203&ptid=1911]david 发表于 2013-9-3 21:53[/url]
搞撒子去了。我也最近刚换工作。跟视频这块没啥大关系了。[/quote]

刚刚进公司,在弄3520D和3515A的rtl8306e的驱动啊,弄的欲仙欲死啊。

blacktulip7

0个粉丝

3

问答

0

专栏

0

资料

blacktulip7 2013-09-05 20:37:37
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=4215&ptid=1911]shuiguozhi 发表于 2013-9-5 09:49[/url]
那可真是痛苦,所有工具都用过了,找不出来区别。NALU_TOOL都用了。谁救救我哦[/quote]

哎,都是一样的痛苦啊,交个朋友吧,我在深大这边上班
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

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

Markdown 语法

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

举报类型

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

详细说明

易百纳技术社区