<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16441">
<STYLE>@font-face {
        font-family: 宋体;
}
@font-face {
        font-family: Verdana;
}
@font-face {
        font-family: @宋体;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; layout-grid: 15.6pt; }
P.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
LI.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
DIV.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
        FONT-STYLE: normal; FONT-FAMILY: Verdana; COLOR: windowtext; FONT-WEIGHT: normal; TEXT-DECORATION: none; mso-style-type: personal-compose
}
DIV.Section1 {
        page: Section1
}
UNKNOWN {
        FONT-SIZE: 10pt
}
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>
</HEAD>
<BODY style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt">
<DIV><FONT color=#000080 size=2 face=Verdana>I guess the data may be 
audio frame, not video frame.  The data should be filtered before sending 
at the server end.</FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Verdana></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Verdana></FONT> </DIV>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana>2012-03-23 </FONT></DIV><FONT 
color=#000080 size=2 face=Verdana>
<HR style="WIDTH: 100px" align=left color=#b5c4df SIZE=1>
</FONT>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana><SPAN>huanggh0108</SPAN> 
</FONT></DIV>
<HR color=#b5c4df SIZE=1>

<DIV><FONT size=2 face=Verdana><STRONG>发件人:</STRONG> Yinxia </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>发送时间:</STRONG> 2012-03-23  00:52:01 
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>收件人:</STRONG> libav-user </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>抄送:</STRONG> </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>主题:</STRONG> [Libav-user] Decoding 
Problem (got_picture always return 0) </FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>
<DIV>Hi dear all,</DIV>
<DIV></DIV>
<DIV>I am a newbie to ffmpeg and I would like to decode the bitstream, which is</DIV>
<DIV>encoded using libx264 at the server end and sent to client frame by frame.</DIV>
<DIV></DIV>
<DIV>I wrote a function decodeFrame to decode this bitstream frame by frame,</DIV>
<DIV>this function is called in a loop, each time recieves a new frame:</DIV>
<DIV></DIV>
<DIV>void decodeFrame( int size, unsigned char *data)</DIV>
<DIV>{</DIV>
<DIV> avpkt.size = size;</DIV>
<DIV>avpkt.data = (uint8_t *)(data);</DIV>
<DIV></DIV>
<DIV>/*decode each frame*/</DIV>
<DIV> len = avcodec_decode_video2(c, picture, &got_picture, avpkt.size);</DIV>
<DIV>if (len < 0) {</DIV>
<DIV> fprintf(stderr, "[avcodec][Err] Error while decoding frame %d\n",frame);</DIV>
<DIV> exit(1);</DIV>
<DIV>}</DIV>
<DIV> if (got_picture) {</DIV>
<DIV>printf("[avcodec] Saving frame %3d\n",frame);</DIV>
<DIV> fflush(stdout);</DIV>
<DIV>_snprintf(buf, sizeof(buf), "/temp/video%d.pgm", frame); // not found</DIV>
<DIV> pgmSave(picture->data[0], picture->linesize[0], c->width, c->height, buf);</DIV>
<DIV> frame++;</DIV>
<DIV>}</DIV>
<DIV>}</DIV>
<DIV></DIV>
<DIV>I can successfully get the value of len, which is exactly the size of</DIV>
<DIV>frame, however, *the value of *got_picture *is always 0. *Can anyone help</DIV>
<DIV>me with this?</DIV>
<DIV>*</DIV>
<DIV>*</DIV>
<DIV>PS. this is the init function of decoder.</DIV>
<DIV></DIV>
<DIV>void initDecoder()</DIV>
<DIV>{</DIV>
<DIV>avcodec_register_all();</DIV>
<DIV></DIV>
<DIV>av_init_packet(&avpkt);</DIV>
<DIV>memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);</DIV>
<DIV> printf("[avcodec] Frame decoding initializing\n");</DIV>
<DIV></DIV>
<DIV>/*choose correct video decoder*/</DIV>
<DIV> codec = avcodec_find_decoder(CODEC_ID_MPEG4);</DIV>
<DIV>if ( !codec ) {</DIV>
<DIV>fprintf(stderr, "[avcodec][Err] codec not found!\n");</DIV>
<DIV> exit(1);</DIV>
<DIV>}</DIV>
<DIV></DIV>
<DIV>c = avcodec_alloc_context3(codec);</DIV>
<DIV> picture = avcodec_alloc_frame();</DIV>
<DIV></DIV>
<DIV>if(codec->capabilities&CODEC_CAP_TRUNCATED)</DIV>
<DIV>           c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete</DIV>
<DIV>frames */</DIV>
<DIV></DIV>
<DIV>    /* open it */</DIV>
<DIV>    if (avcodec_open2(c, codec, NULL) < 0) {</DIV>
<DIV>        fprintf(stderr, "[avcodec][Err] could not open codec\n");</DIV>
<DIV>        exit(1);</DIV>
<DIV>    }</DIV>
<DIV></DIV>
<DIV></DIV>
<DIV>frame = 0;</DIV>
<DIV></DIV>
<DIV>}</DIV>
<DIV></DIV>
<DIV></DIV>
<DIV>Thank you very much!</DIV>
<DIV>Yinxia</DIV>
<DIV></DIV>
<DIV></DIV>
<DIV>--</DIV>
<DIV>View this message in context: http://libav-users.943685.n4.nabble.com/Decoding-Problem-got-picture-always-return-0-tp4496039p4496039.html</DIV>
<DIV>Sent from the libav-users mailing list archive at Nabble.com.</DIV>
<DIV>_______________________________________________</DIV>
<DIV>Libav-user mailing list</DIV>
<DIV>Libav-user@ffmpeg.org</DIV>
<DIV>http://ffmpeg.org/mailman/listinfo/libav-user</DIV>
<DIV></DIV></FONT></DIV></BODY></HTML>