Question

I am writing an audio decoder based on ffmpeg for android, where I have to decode aac audio, but because of some reason it always returns 0 bytes decoded.

Looks like I pass everything right. Can anybody tell me what went wrong in my case.I copied code from ffplay.c. What is the reason avcodec_decode_audio3 function always returns zero?

Here is the code from ffplay.c :

AVPacket *pkt_temp = &is->audio_pkt_temp;
    AVPacket *pkt = &is->audio_pkt;
    AVCodecContext *dec= is->audio_st->codec;
    int n, len1, data_size;
    double pts;

          data_size = sizeof(is->audio_buf1);
        len1 = avcodec_decode_audio3(dec, (int16_t *)is->audio_buf1, &data_size, pkt_temp);
        if (len1 < 0) {
            pkt_temp->size = 0;
            break;
        } 

       if (data_size <= 0){
                   //This block always gets executed.
            continue;
    }
Was it helpful?

Solution

I am able to resolve my problem, not with the above code. But I completely rewrote my audio code, which doesn't have any threads or waiting mechanism. I suspect that the problem doesn't lie in the above code, but it is in the way I pass the data to a function.

OTHER TIPS

When you do:

data_size = sizeof(is->audio_buf1);

You are getting the size of a pointer, instead of the size of the buffer pointed by is->audio_buf1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top