[Libav-user] AAC encoding error

Paul B Mahol onemda at gmail.com
Mon Apr 8 10:35:43 CEST 2013


On 4/7/13, Justin <justin-zhao at qq.com> wrote:
> Hi,
>
>     I am trying to encode audio using the AAC audio encoder with the program
> below, but when I call the avcodec_open2 funtion, the function always return
> -733130664. I don't know where is wrong in it. I'll very appreciate someone
> who can point out the wrong.

Native AAC encoder is experimental and so you need to set additional
flag to use.

>
> note:if the codec AV_CODEC_ID_AAC is changed as AV_CODEC_ID_MP2, the
> avcodec_open2 can return 0 successfully!
>
> ============program=================
> main()
> {
>  int ret;
>  AVCodec *codec;
>  AVCodecContext *c;
>  AVFrame *frame;
>
>  avcodec_register_all();
>  codec = avcodec_find_encoder(AV_CODEC_ID_AAC);
>  if (!codec)  return;
>  //avcodec_register(codec);
>  c = avcodec_alloc_context3(codec);
>  if (!c)  return;
>
>  c->bit_rate = 64000;
>  c->sample_rate    = 44100;
>  c->channels       = 2;
>  c->frame_size = 88200;
>  c->sample_fmt = AV_SAMPLE_FMT_S16;
>  // open it
>  ret = avcodec_open2(c, codec, NULL);
>  if (ret >= 0)  printf("OK\r\n");
> }
>
> Best Regards,
> Justin


More information about the Libav-user mailing list