<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font color="#795e26" face="Consolas, Courier New, monospace"><span style="font-size:14px;white-space:pre-wrap">Very surprsing, Can't we get basic details about stream without decoding using libavcodec APIs like width,height.?<br></span></font></div></blockquote><div>It's all part of sps/pps. I am using  <span style="color:rgb(121,94,38);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap">av_parser_parse2() API, which forms an AVC frame.</span></div><div><font color="#795e26" face="Consolas, Courier New, monospace"><span style="font-size:14px;white-space:pre-wrap">Please help.</span></font></div><div><span style="color:rgb(121,94,38);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><br></span></div><div><span style="color:rgb(121,94,38);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap">Output:</span></div><div>{profile=100 level=31 width=0 height=0 codedwidth=0 codedheight=0 pix_fmt=(null) aspectRatio=0:1         frameRate=0:1 slices=0 } </div><div><br></div><div><div style="color:rgb(0,0,0);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap">Code: /*In my case there is no Input File, I get H264-ES in "data" as below*/</div><div style="color:rgb(0,0,0);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap">
<div style="line-height:19px"><div>AVCodec* codec = <span style="color:rgb(121,94,38)">avcodec_find_decoder</span>(AV_CODEC_ID_H264);</div></div><div style="line-height:19px"><div>AVCodecParserContext* parser = <span style="color:rgb(121,94,38)">av_parser_init</span>(<span style="color:rgb(0,16,128)">codec</span>-><span style="color:rgb(0,16,128)">id</span>);</div></div></div></div><div><div style="color:rgb(0,0,0);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div>AVCodecContext* dec_ctx;</div><div><div style="line-height:19px"><div>dec_ctx = <span style="color:rgb(121,94,38)">avcodec_alloc_context3</span>(codec);</div><div><div style="line-height:19px"><div><span style="color:rgb(121,94,38)">av_parser_parse2</span>(parser, dec_ctx, &<span style="color:rgb(0,16,128)">pkt</span>-><span style="color:rgb(0,16,128)">data</span>, &<span style="color:rgb(0,16,128)">pkt</span>-><span style="color:rgb(0,16,128)">size</span>,</div><div>                                   data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, <span style="color:rgb(9,134,88)">0</span>);</div></div>
<div style="line-height:19px"><div><span style="color:rgb(175,0,219)">if</span> (<span style="color:rgb(0,16,128)">pkt</span>-><span style="color:rgb(0,16,128)">size</span>)</div><div>    { </div><div>        <span style="color:rgb(121,94,38)">printf</span>(<span style="color:rgb(163,21,21)">"{profile=%d level=%d width=%d height=%d codedwidth=%d codedheight=%d pix_fmt=%s aspectRatio=%d:%d </span><span style="color:rgb(205,49,49)">\ </span></div></div></div></div></div></div></div><div><div style="color:rgb(0,0,0);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(163,21,21)">        frameRate=%d:%d slices=%d }</span><span style="color:rgb(238,0,0)">\n</span><span style="color:rgb(163,21,21)">"</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">profile</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">level</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">width</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">height</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">coded_width</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">coded_height</span>,</div><div>        <span style="color:rgb(121,94,38)">av_get_pix_fmt_name</span>((AVPixelFormat)<span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">pix_fmt</span>),</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">sample_aspect_ratio</span>.<span style="color:rgb(0,16,128)">num</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">sample_aspect_ratio</span>.<span style="color:rgb(0,16,128)">den</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">framerate</span>.<span style="color:rgb(0,16,128)">num</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">framerate</span>.<span style="color:rgb(0,16,128)">den</span>,</div><div>        <span style="color:rgb(0,16,128)">dec_ctx</span>-><span style="color:rgb(0,16,128)">slices</span></div><div>        );</div><div>}</div></div></div></div>