6

I have upgraded my ffmpeg version to the latest commit and Now I can see that the audio decoding funciton avcodec_decode_audio3 has been deprecated and when I use the new function avcodec_decode_audio4, as per the changes required in it, I get the error as

[amrnb @ 003a5000] get_buffer() failed.

I am not able to find what causes this error. Anyone has a sample example of usng this new function:

avcodec_decode_audio4((AVCodecContext *avctx, AVFrame *frame,int *got_frame_ptr, AVPacket *avpkt);

Chillie
  • 1,030
  • 10
  • 28
NitinG
  • 893
  • 3
  • 21
  • 38
  • 1
    I've got the same problem with AAC files. Have you figured out a solution in the end? – L__ Oct 20 '13 at 04:38

1 Answers1

3

Check decoding_encoding.c example from ffmpeg source. It uses function avcodec_decode_audio4.

Dmitry Shkuropatsky
  • 3,902
  • 2
  • 21
  • 13
  • Thanks I have used the same example and just simply copy pasted the code from this and still the len comes as -22 and it returns the error as get_buffer() failed. – NitinG Feb 22 '12 at 15:51
  • What kind of media is this? Can you decode it with ffmpeg, or play in ffplay? – Dmitry Shkuropatsky Feb 22 '12 at 16:51
  • 1
    its amr_nb audio. I have successfully decoded with previous version of ffmpeg with audio3 function. Also, i have tried using latest windows binaries of ffmpeg and i am able to decode and play the decoded audio. This issue is coming only when i try to decode with audio4 function in my application for same media. – NitinG Feb 22 '12 at 18:31
  • Strange, `avcodec_decode_audio3` calls `avcodec_decode_audio4`, see [util.c](https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/utils.c). Are you sure that input buffer is of sufficient size and not underunning? Also, does it fail on the first or the second decode call, or sometime later? – Dmitry Shkuropatsky Feb 22 '12 at 21:51
  • Yeah, i have checked that as well, inbuf is fine with inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; so, the input input buffer is avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f); thus it should be suficent enough. Also, it fails on the first time itself on the first decode call. The error seems strange. Any specific reason for this error in your knowledge? – NitinG Feb 23 '12 at 05:29
  • Just guessing that pixel format or number of samples is not initialized, and `av_samples_get_buffer_size` returns error (EINVAL = 22). But that would not explain why `avcodec_decode_audio3` works. – Dmitry Shkuropatsky Feb 23 '12 at 18:33
  • No., as i have explained ,avcodec_decode_audio3 only worked in previous version of ffmpeg when it was not deprecated and not in the nwere version, as in the newer version, after deprecation, it is only using the avcodec_decode_audio4 function and it just acts as a wrapper as shown in utils.c. So, it must be related to something related to buffer in the newer version and the issue is coming for both audio3 and audio4 as internally both of the functions are same. – NitinG Feb 24 '12 at 07:55
  • It appears to be a regression. I'd check another build of ffmpeg. You can also report the problem. I wonder if it is specific to amrnb, or other formats are affected as well. – Dmitry Shkuropatsky Feb 24 '12 at 15:54