[Libav-user] AudioToolbox AudioBufferList to/from AVFilter

Ronak ronak2121 at yahoo.com
Tue Nov 28 18:45:17 EET 2017


I managed to trace this down to av_frame_get_buffer returning -22.

Here's the code that I tried:

  AVFrame *audioFrame = av_frame_alloc();
  audioFrame->channels = 2;
  audioFrame->channel_layout = av_get_default_channel_layout(2);
  audioFrame->sample_rate = 44100;
  audioFrame->nb_samples = buffer->mBuffers[0].mDataByteSize/ sizeof(Float32) * 44100;
  audioFrame->pts = audioFrame->nb_samples;
  av_frame_get_buffer(audioFrame, 0); <--- returns -22

  audioFrame->extended_data[0] = buffer->mBuffers[0].mData;
  audioFrame->extended_data[1] = buffer->mBuffers[1].mData;
  audioFrame->linesize[0] = buffer->mBuffers[0].mDataByteSize;

  AVFrame *otherFrame = av_frame_alloc();
  int result2 = av_frame_ref(otherFrame, audioFrame); <--- returns -22
  
  int result = av_buffersrc_write_frame(self.bufferContext, audioFrame);

Why would av_frame_get_buffer return -22? Am I not supposed to call it? What about write frame?


> On Nov 27, 2017, at 7:19 PM, Ronak Patel <ronak2121-at-yahoo.com at ffmpeg.org> wrote:
> 
> Hi Paul,
> 
> Do you mind pointing me to the relevant documentation?
> 
> I tried setting up an AVFrame instance with the sample rate, channel layout and data but the calls to av_frame_ref are failing with -22 errors. I’m looking for any sample code that shows how to properly initialize an AVFrame from an AudioBufferList.
> 
> Thanks
> 
> Ronak
> 
> Sent from my iPhone
> 
>> On Nov 26, 2017, at 2:17 PM, Paul B Mahol <onemda at gmail.com> wrote:
>> 
>>> On 11/26/17, Ronak <ronak2121-at-yahoo.com at ffmpeg.org> wrote:
>>> Hi,
>>> 
>>> I'm trying to build a graphic equalizer using the ffmpeg library for iOS,
>>> wrapping the AVFilter library in an AUAudioUnit.
>>> 
>>> I'm having trouble figuring out how to convert an AudioBufferList's data to
>>> an AVFilter and back. The input buffers are in stereo, so I'm also unsure
>>> how to pass in both data arrays.
>>> 
>>> Does anyone know how to do this?
>> 
>> Have you read already available documentation?
>> 
>> AVFrame stores samples for packed format into AVFrame->data[0].
>> And planar format into AVFrame->extended_data[ X ], where X is channel number.
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
> 
> _______________________________________________
> 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/20171128/e144c613/attachment.html>


More information about the Libav-user mailing list