[Libav-user] AVFRame for MP3 behavior

Dr. Sven Alisch svenali at t-online.de
Fri Oct 7 10:53:41 EEST 2022


Dear Developer,

I have an understanding question. If I initialing a AVFrame with PCM Data like this:

error = avcodec_fill_audio_frame(
       output_frame,
       2,
       AV_SAMPLE_FMT_FLTP,
       (uint8_t*)output_frame_data,
       frame_size * sizeof(float),
       0);

I always get an error. -22, which means illegal argument. Frame_size * sizeof(float) is 4608 Bytes (1152 FrameSize * 4 Byte), which is the size for a MP3-Frame. My input is PCM Stereo. But why do I get this error? A FrameSize for mp3 is 1152. FLTP means, ok, 2 channels, float and a 2 dimensional array of bytes (right?). But how to initiate right? If I use:

error = avcodec_fill_audio_frame(
       output_frame,
       2,
       AV_SAMPLE_FMT_FLTP,
       (uint8_t*)output_frame_data,
       2 * frame_size * sizeof(float),
       0);

It works, but then the encoder

ret = avcodec_send_frame(_CodecContext, output_frame);

Returns with -22 (illegal argument). I am confused. How to send the frames in a right way to the encoder? The PCM data I read from an AVFifo as suggested by transcoder_aac.c.

Thanks!

Regards,
Sven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20221007/1a194fe1/attachment.sig>


More information about the Libav-user mailing list