<div dir="ltr"><div dir="ltr">On Sun, Jun 6, 2021 at 9:58 PM <a href="mailto:aszswaz@163.com">aszswaz@163.com</a> <<a href="mailto:aszswaz@163.com">aszswaz@163.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am using libavcodec to mp3 encoding the pcm recording file collected <br>
by alsa. Please refer to the attachment for the code. Although the code <br>
can run successfully, the following error will occur:<br>
<br>
[libmp3lame @ 0x5653c7e9b880] 5 frames left in the queue on closing.<br>
<br>
I want to ask you a few questions:<br>
<br>
1. What is the reason for this error?<br></blockquote><div>It means that there are still 5 frames not being encoded.</div><div>The encoder may group a few frames together to encode more efficiently. It still expects more raw samples.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
2. How does this error affect the mp3 audio?<br></blockquote><div>The audio file will miss 5 frames of samples at the end.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
3. How can I solve it?<br></blockquote><div>You need to tell the encoder there are no more frames to be sent, by calling avcodec_send_frame() with a NULL frame at the end. After that, keep calling avcodec_receive_packet() until EOF is returned.<br>It is documented in avcodec_send_frame() in avcodec.h.<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Here is a detailed information:<br>
<br>
computer system: Manjaro x86_64<br>
<br>
linux kernel version: Linux 5.12.2-1<br>
<br>
ALSA version: Advanced Linux Sound Architecture Driver Version <br>
k5.12.2-1-MANJARO.<br>
<br>
ffmpeg version: ffmpeg version n4.4 Copyright (c) 2000-2021 the FFmpeg <br>
developers<br>
<br>
Thank you for reading my mail.<br>
<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div></div>