[Libav-user] Audio frames and resampling
Michael IV
explomaster at gmail.com
Wed Mar 14 14:03:48 EET 2018
Hi.I have the following case:
I am receiving audio stream which consist
of 2 channel float 32 (non planar) audio frames. Then I am trying to
convert those into
AV_SAMPLE_FMT_FLTP in order to encode with AAC codec. The problem is that I
receive that data as packets of size different from what my AVFrame has.
AVFrame for
this codec has 2 buffers,each 1024 samples,which is 4096 bytes per channel
(32bit sample size),right? So it looks like I have to fill the frame with
all 4096 bytes before pushing it into encoder?Is it possible to submit
'custom' frames,with different amount of data from what I am getting in
codec context?
Second question:
I resample from non planar FLT to FLTP as follows:
const unsigned char *srcplanes[2];
unsigned char *dstplanes[2];
srcplanes[0] = (unsigned char*)packet.data;
srcplanes[1] = NULL;
dstplanes[0] = (unsigned char*)mAudioInputFrame->data[0];
dstplanes[1] = (unsigned char*)mAudioInputFrame->data[1];
int framesToWrite = packet.dataSize / 8;
int samples = (int)av_rescale_rnd(NumFramesWritten, 44100, 44100,
AV_ROUND_UP);
int samplesConverted = swr_convert(swrCxt, dstplanes, samples, srcplanes,
framesToWrite );
Here, *packet.data* is the src audio data buffer from the stream,which has
almost half of the size of the mAudioInputFrame, which has 4096 bytes per
channel. So how does swr_convert know how many bytes to take from the
srcplanes?
Does it operate based on the size of the destination frame? If yes,then it
means I have to provide *packet.data * with data size EXACTLY equal the
size of the destination AVFrame buffers?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180314/c3e3edc1/attachment.html>
More information about the Libav-user
mailing list