Opened 3 years ago

Last modified 3 years ago

#9223 new defect

Example transcode_aac does not drain queue

Reported by: whatdoido Owned by:
Priority: normal Component: documentation
Version: git-master Keywords: aac
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:
Example transocde_aac.c does not drain queue, resulting in "frames left in queue on closing" warning messages and samples/frames lost.

It makes learning/reusing code as framework difficult.

How to reproduce:

#build ffmpeg doc/examples
$ make -f Makefile.example
#generate a simple wav file
$ ffmpeg -f lavfi -i 'sine=frequency=300:beep_factor=4:duration=5' -b:a 96k -ar 44100 -t 5 foo.wav

$ ./transcode_aac foo.wav foo.aac
[aac @ 0x1e299c0] Qavg: 55159.750
[aac @ 0x1e299c0] 1 frames left in the queue on closing

An attempt to drain the Q exists (a loop calling encode_audio_frame() will a NULL frame), but it mishandles the avcodec_send_frame() return code, forcing it to cleanup upon EOF (as result of sending a NULL frame) instead of continuing to avcodec_recieve_frame() and av_write_frame()

Simple fix.

diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index 73786ab59b..a6c1089014 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -685,7 +685,6 @@ static int encode_audio_frame(AVFrame *frame,
     /* The encoder signals that it has nothing more to encode. */
     if (error == AVERROR_EOF) {
         error = 0;
-        goto cleanup;
     } else if (error < 0) {
         fprintf(stderr, "Could not send packet for encoding (error '%s')\n",

Change History (1)

comment:1 by Carl Eugen Hoyos, 3 years ago

Keywords: transocding removed
Note: See TracTickets for help on using tickets.