[FFmpeg-trac] #9223(documentation:new): Example transcode_aac does not drain queue

FFmpeg trac at avcodec.org
Fri May 7 13:01:32 EEST 2021


#9223: Example transcode_aac does not drain queue
-------------------------------------+-------------------------------------
             Reporter:  whatdoido    |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:  git-
  documentation                      |  master
             Keywords:  aac          |               Blocked By:
  transocding                        |
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 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",
                  av_err2str(error));
 }}}
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9223>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list