ffmpeg libfdk-aac open coder error and show The encoder timebase is not set

Viewed 229

I try to encode some pcm data,and I compile ffmpeg for myself with libfdk-aac,but When I use a aac encoder,It shows timebase is not set,but aac data seems not need a timebase,and even I set the timebase,it shows the same error again

here is the Initializationcode:

    AVCodec *pCodec;
    AVCodecContext *pCodecCtx = NULL;
    int i, ret, got_output;
    FILE *fp_in;
    FILE *fp_out;

    AVFrame *pFrame;
    uint8_t* frame_buf;
    int size = 0;

    AVPacket pkt;
    int y_size;
    int framecnt = 0;

    char filename_in[] = "tdjm.pcm";

    AVCodecID codec_id = AV_CODEC_ID_AAC;
    char filename_out[] = "tdjm.aac";

    int framenum = 1000;

    avcodec_register_all();

    pCodec = avcodec_find_encoder_by_name("libfdk_aac");
    if (!pCodec) {
        printf("Codec not found\n");
        return -1;
    }
    pCodecCtx = avcodec_alloc_context3(pCodec);
    if (!pCodecCtx) {
        printf("Could not allocate video codec context\n");
        return -1;
    }

    //pCodecCtx->codec_id = codec_id;
    pCodecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
    pCodecCtx->sample_fmt = AV_SAMPLE_FMT_S16;
    pCodecCtx->sample_rate = 44100;
    pCodecCtx->channel_layout = AV_CH_LAYOUT_STEREO;
    pCodecCtx->channels = av_get_channel_layout_nb_channels(pCodecCtx->channel_layout);
    pCodecCtx->bit_rate = 64000;
    pCodecCtx->time_base = AVRational{1,10};

    if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) {
        printf("Could not open codec\n");
        return -1;
    }
0 Answers
Related