[Libav-user] avcodec_decode_video2 got_picture parameter returns zero sometimes

Li Zhang lizhang at utelisys.com
Fri May 25 16:42:12 CEST 2012


Hi,

I also got the similar problem.


I used  avcodec_decode_video2() to decode mpeg2 video and avcodec_decode_audio4() to decode audio in TS.  Most of the time the decoding is correct. But sometimes it will fail. And the audio decoding is far more failure than video decoding.

Now if the video decoding is failed, I will duplicate the last frame. If the audio decoding is failed, I will insert a silent packet into output stream.


I do not know why they failed. Can anyone can help us?


That is the code I used:

For video:
                        len = avcodec_decode_video2(vCodecCtx, oVFrame, &frameFinished, &packet);

                        if((0 > len) || (0 >= frameFinished)) {
                                printf("Error decoding. The video frame index is: %d\n", outs->video_frame_index);
                       }

For audio:
                        ret = avcodec_decode_audio4(aCodecCtx,oAFrame,&is_audio_valid, &packet);
                        if((0 > ret) || (0 >= is_audio_valid)) {
                                printf("audio: Error decoiding, ret=%d,the audio frame index is: %lld\n", ret, out->audio_frame_index);

                      }


And I got the following results:

audio: Error decoiding, ret=-1094995529,the audio frame index is: 180333
audio: Error decoiding, ret=-1094995529,the audio frame index is: 194069
audio: Error decoiding, ret=-1094995529,the audio frame index is: 194287
audio: Error decoiding, ret=-1094995529,the audio frame index is: 222202
audio: Error decoiding, ret=-1094995529,the audio frame index is: 222212
audio: Error decoiding, ret=-1094995529,the audio frame index is: 222214
audio: Error decoiding, ret=-1094995529,the audio frame index is: 236272
audio: Error decoiding, ret=-1094995529,the audio frame index is: 236273
audio: Error decoiding, ret=-1094995529,the audio frame index is: 250601
audio: Error decoiding, ret=-1094995529,the audio frame index is: 264342
audio: Error decoiding, ret=-1094995529,the audio frame index is: 292479
audio: Error decoiding, ret=-1094995529,the audio frame index is: 292482
audio: Error decoiding, ret=-1094995529,the audio frame index is: 292505
audio: Error decoiding, ret=-1094995529,the audio frame index is: 292511
audio: Error decoiding, ret=-1094995529,the audio frame index is: 292801
audio: Error decoiding, ret=-1094995529,the audio frame index is: 306571
audio: Error decoiding, ret=-1094995529,the audio frame index is: 306829
audio: Error decoiding, ret=-1094995529,the audio frame index is: 306843
audio: Error decoiding, ret=-1094995529,the audio frame index is: 306846
audio: Error decoiding, ret=-1094995529,the audio frame index is: 320645
audio: Error decoiding, ret=-1094995529,the audio frame index is: 320855
audio: Error decoiding, ret=-1094995529,the audio frame index is: 320910
audio: Error decoiding, ret=-1094995529,the audio frame index is: 334672
audio: Error decoiding, ret=-1094995529,the audio frame index is: 334887
audio: Error decoiding, ret=-1094995529,the audio frame index is: 334949
audio: Error decoiding, ret=-1094995529,the audio frame index is: 348727
audio: Error decoiding, ret=-1094995529,the audio frame index is: 348730
audio: Error decoiding, ret=-1094995529,the audio frame index is: 350134
audio: Error decoiding, ret=-1094995529,the audio frame index is: 362777
audio: Error decoiding, ret=-1094995529,the audio frame index is: 362791
audio: Error decoiding, ret=-1094995529,the audio frame index is: 362794
audio: Error decoiding, ret=-1094995529,the audio frame index is: 377155
audio: Error decoiding, ret=-1094995529,the audio frame index is: 390910
audio: Error decoiding, ret=-1094995529,the audio frame index is: 391142
audio: Error decoiding, ret=-1094995529,the audio frame index is: 404941
audio: Error decoiding, ret=-1094995529,the audio frame index is: 404949
audio: Error decoiding, ret=-1094995529,the audio frame index is: 405173
audio: Error decoiding, ret=-1094995529,the audio frame index is: 405234
audio: Error decoiding, ret=-1094995529,the audio frame index is: 405249
audio: Error decoiding, ret=-1094995529,the audio frame index is: 405252
audio: Error decoiding, ret=-1094995529,the audio frame index is: 405960
audio: Error decoiding, ret=-1094995529,the audio frame index is: 418995
audio: Error decoiding, ret=-1094995529,the audio frame index is: 419004
audio: Error decoiding, ret=-1094995529,the audio frame index is: 419009
audio: Error decoiding, ret=-1094995529,the audio frame index is: 419284
audio: Error decoiding, ret=-1094995529,the audio frame index is: 433297
audio: Error decoiding, ret=-1094995529,the audio frame index is: 433354
audio: Error decoiding, ret=-1094995529,the audio frame index is: 433355
audio: Error decoiding, ret=-1094995529,the audio frame index is: 433373
audio: Error decoiding, ret=-1094995529,the audio frame index is: 435408
audio: Error decoiding, ret=-1094995529,the audio frame index is: 447131
audio: Error decoiding, ret=-1094995529,the audio frame index is: 447428
audio: Error decoiding, ret=-1094995529,the audio frame index is: 461200
audio: Error decoiding, ret=-1094995529,the audio frame index is: 475537
audio: Error decoiding, ret=-1094995529,the audio frame index is: 475538
audio: Error decoiding, ret=-1094995529,the audio frame index is: 475554




Best regards,

Li

________________________________________
From: libav-user-bounces at ffmpeg.org [libav-user-bounces at ffmpeg.org] On Behalf Of NITIN GOYAL [nitinkumgoyal at gmail.com]
Sent: Friday, May 25, 2012 7:57 AM
To: This list is about using libavcodec, libavformat, libavutil,        libavdevice and libavfilter.
Subject: Re: [Libav-user] avcodec_decode_video2 got_picture parameter returns zero sometimes

wht do you mean by sometimes?

if its not consistent then i wonder the data frame you are sending are not correct.

if its consistent and always results zero then either the NAL formation have some issue or you are missing some important configuration.

On Fri, May 25, 2012 at 10:21 AM, <krishnaks at iwavesystems.com<mailto:krishnaks at iwavesystems.com>> wrote:
Here sometimes got_picture_ptr returns zero  which means frames could not
be decompressed.
What may be the reason? I am getting the H264 frame without any loss.
ANy configuration option I am missing?



More information about the Libav-user mailing list