[Libav-user] AAC encoding error

Justin justin-zhao at qq.com
Fri Apr 12 06:25:43 CEST 2013


Hello,
 
    Now, I have already called the avcodec_open2 function successfully by calling av_dict_set(&opts, "strict", "experimental", 0) firstly. But now I run into an other problem again: when I call the avcodec_encode_audio2(c, &pkt, frame, &got_output) firstly, it returned 0 and the got_output is 0 too, and when I call the avcodec_encode_audio2(c, &pkt, frame, &got_output) secondly, it'll incur an address accessing error: read 0xFFFFFFFF. I don't know what I have made mistake, and I have no any way now. I'll very appreciate anyone who can help me, thanks very much.
 
the program is attached as following, here the srcdata is a pointer array, srcdata[1] = srcdata[0] + 4096, and they all have been filled original audio data befor the while loop.  I have try to replace the avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt, (const uint8_t*)pCurSource, m_SrcBuffLen, 0); with frame->data[0] = srcdata[0]; frame->data[1] = srcdata[1]; but the problem still exists.
 
note: I used the ffmpeg native AAC encoder, and I have found and opened the encoder successfully.
 
=============program==============
  got_output =  0;
  offset = 0;
  while(i<10)
  {
     i++;

     av_init_packet(&pkt);
     pkt.data = NULL;    // packet data will be allocated by the encoder
     pkt.size = 0;

     pCurSource = srcdata[0];

     ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
              (const uint8_t*)pCurSource, m_SrcBuffLen, 0);

     /* encode the samples */
     ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
   
     if (ret >= 0 && pDest != NULL && got_output && pkt.data != NULL && pkt.size > 0)
    {
      memcpy(pDest + destLen, pkt.data, pkt.size);
      destLen = destLen + pkt.size;
      av_free_packet(&pkt);
     }
  }
 
------------------
Justin




------------------ Original ------------------
From:  "Justin"<justin-zhao at qq.com>;
Date:  Tue, Apr 9, 2013 05:54 PM
To:  "This list is about using libavcodec, libavformat, libavutil,libavdevice and libavfilter."<libav-user at ffmpeg.org>; 

Subject:  Re: [Libav-user] AAC encoding error



I have done as your way, and pleasantly found that it really worked sucessfully.
 
I very appreciate you, thank you very much again.
 
------------------
Best Regards,
Justin




------------------ Original ------------------
From:  "Andrey Utkin"<andrey.krieger.utkin at gmail.com>;
Date:  Tue, Apr 9, 2013 07:42 AM
To:  "This list is about using libavcodec, libavformat, libavutil,libavdevice and libavfilter."<libav-user at ffmpeg.org>; 

Subject:  Re: [Libav-user] AAC encoding error



2013/4/8 Justin <justin-zhao at qq.com>:
> But, how can I set the additional flag? thank you very much.

This way:

AVDictionary *opts = NULL;
av_dict_set(&opts, "strict", "experimental", 0);
int ret = avcodec_open2(encoder_context, codec, &opts);
av_dict_free(&opts);
_______________________________________________
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/20130412/a76ba11a/attachment.html>


More information about the Libav-user mailing list