[Libav-user] Decoding Problem (got_picture always return 0)

ZHAO Yinxia hydezhao at gmail.com
Fri Mar 23 14:10:47 CET 2012


Hi huanggh0108,

I am sure I have no audio frame... While, I use libx264 to encode the
frames, and I am not sure I chose the right CODEC_ID for decoding.

I use CODEC_ID_MPEG4. CODEC_ID_H264 looks more reasonable, but returns a
"no frame" error.

2012/3/23 huanggh0108 <huanggh0108 at sina.com>

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


More information about the Libav-user mailing list