<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=UTF-8" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
        MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em; MARGIN-TOP: 0px
}
OL {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
UL {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
DIV.FoxDiv20150822011210349497 {
        COLOR: #000000
}
P {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
BODY {
        FONT-SIZE: 10.5pt; FONT-FAMILY: ?¢èí??oú; COLOR: #000080; LINE-HEIGHT: 1.5
}
</STYLE>

<META name=GENERATOR content="MSHTML 11.00.9600.17801"></HEAD>
<BODY style="MARGIN: 10px">
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>I have the same issue.</DIV>
<DIV> </DIV>
<DIV>At the beginning, aac encoder doesn't output coded data for the first two 
frames, which means encoder begins to output coded data from 3rd frame. In the 
end, all audio samples are sent to aac encoder, but coded data of last 
samples are not output yet.</DIV>
<DIV> </DIV>
<DIV>I know how to flush delayed frames in h264 encoder, i.e. flush operation 
uses avcodec_encode_video()/avcodec_encode_video2() like encoding operation. But 
avcodec_encode_audio()/avcodec_encode_audio2()  can't flushed delayed 
samples in aac encoder, as aac encoder doesn't have 
the AV_CODEC_CAP_DELAY capability set.</DIV>
<DIV> </DIV>
<DIV>'int avcodec_encode_audio2( AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr ) 
' is the function of encoding a audio frame. If 3rd argument frame is set to 
NULL, aac encoder won't flush delayed samples, as aac encoder doesn't have 
the AV_CODEC_CAP_DELAY capability set.</DIV>
<DIV> </DIV>
<DIV>Which ffmpeg function can flush delayed aac samples? How to flush 
those samples?</DIV>
<DIV> </DIV>
<DIV>I have tried one way to flush those samples. Having sent all audio frames 
to aac encoder, I continue send to aac encoder several frames which have 
samples with zero value. AAC does send coded data of delayed samples, but I 
don't think it is good to flush aac encoder.</DIV>
<DIV> </DIV>
<DIV>Is there better way to flush aac encoder?</DIV>
<DIV> </DIV>
<DIV>andrew</DIV>
<DIV> </DIV>
<DIV 
style="BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; BORDER-BOTTOM: medium none; PADDING-BOTTOM: 0cm; PADDING-TOP: 3pt; PADDING-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm">
<DIV 
style="FONT-SIZE: 12px; BACKGROUND: #efefef; COLOR: #000000; PADDING-BOTTOM: 8px; PADDING-TOP: 8px; PADDING-LEFT: 8px; PADDING-RIGHT: 8px">
<DIV><B>From:</B> <A href="mailto:panicosk@gmail.com">Panicos 
Karkallis</A></DIV>
<DIV><B>Date:</B> 2015-08-22 00:44</DIV>
<DIV><B>To:</B> <A href="mailto:libav-user@ffmpeg.org">This list is about 
using libavcodec, libavformat, libavutil, libavdevice and libavfilter.</A></DIV>
<DIV><B>Subject:</B> Re: [Libav-user] AAC encoder not returning final 
samples</DIV></DIV></DIV>
<DIV>
<DIV class=FoxDiv20150822011210349497>
<P dir=ltr>I do flush the encoder by passing a null frame. it returns 2 packets 
that get appended at the beginning of my file and increase the padding instead 
of giving the end samples.</P>
<P dir=ltr>Panicos</P><BR>
<DIV class=gmail_quote>
<DIV dir=ltr>On 17:34, Fri, 21 Aug 2015 Henry, David <<A 
href="mailto:David.Henry@echostar.com" 
target=_blank>David.Henry@echostar.com</A>> wrote:<BR></DIV>
<BLOCKQUOTE class=gmail_quote 
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
  <DIV 
  style="WORD-WRAP: break-word; FONT-SIZE: 14px; FONT-FAMILY: Calibri,sans-serif; COLOR: rgb(0,0,0)">
  <DIV>
  <DIV>
  <DIV>> I am new to ffmpeg/avlib and what I am trying to do is just decode 
  and encode back again an aac file. I don't try to make any changes to the file 
  although the avlib encoder is producing a file with more initial padding than 
  expected and it is cropping the final frames of the audio 
  clip.</DIV></DIV></DIV><SPAN>
  <DIV dir=ltr>
  <DIV>> I exported the avframes created by the decoder and all the file 
  information is there. It is at the encoding step that I am doing something 
  wrong.</DIV></DIV></SPAN>
  <DIV><BR></DIV></DIV>
  <DIV 
  style="WORD-WRAP: break-word; FONT-SIZE: 14px; FONT-FAMILY: Calibri,sans-serif; COLOR: rgb(0,0,0)"><SPAN>
  <DIV dir=ltr>
  <DIV>It sounds like you are not flushing the libfdk-aac encoder at the 
  end.  The encoder holds on to audio samples internally while you are 
  encoding and you need to flush those last samples</DIV></DIV></SPAN>
  <DIV>When you are finished encoding.</DIV>
  <DIV>- 
  David</DIV></DIV>_______________________________________________<BR>Libav-user 
  mailing list<BR><A href="mailto:Libav-user@ffmpeg.org" 
  target=_blank>Libav-user@ffmpeg.org</A><BR><A 
  href="http://ffmpeg.org/mailman/listinfo/libav-user" rel=noreferrer 
  target=_blank>http://ffmpeg.org/mailman/listinfo/libav-user</A><BR></BLOCKQUOTE></DIV></DIV></DIV></BODY></HTML>