I am recording a continuous stream in a high-definition stream of HLS. Then I want to transcode this asynchronously into different formats / bitrates. It works for me, basically, in addition to audio artifacts appear between each segment (spaces and pops).
Here is an example ffmpeg command line:
ffmpeg -threads 1 -nostdin -loglevel verbose \ -nostdin -y -i input.ts -c:a libfdk_aac \ -ac 2 -b:a 64k -y -metadata -vn output.ts
Checking the sample sound file shows that there is a space at the end of the sound:

And the beginning of the file looks suspiciously attenuated (although this may not be a problem):

My suspicion is that these artifacts occur because transcoding occurs without the context of the stream as a whole.
Any ideas on how to convince FFMPEG to create a sound that fits back into the HLS stream?
** UPDATE 1 **
Here is the beginning / end of the source segment. As you can see, the start still looks the same, but the end ends for 30 seconds. I expect some degree of padding with lossy encoding, but I mean that HLS manages to do no-play (is this related to the iTunes method with user metadata?)


** UPDATED 2 **
So, I converted both originals (128k aac to MPEG2 TS) and transcoded (64k aac to aac / adts container) to WAV and placed two side by side. This is the result:


I'm not sure if this is an idea of how the client will play it, but it seems a little strange that decoding a transcoded one introduces a space at the beginning and makes the segment longer. Given that they are lossy encoding, I would expect indentation to be equally present in both (if at all).
** UPDATE 3 **
According to http://en.wikipedia.org/wiki/Gapless_playback - only a few encoders support brushless - for MP3, I switched to lame in ffmpeg and the problem still seems to be gone.
For AAC (see http://en.wikipedia.org/wiki/FAAC ), I tried libfaac (unlike libfdk_aac), and it also seems to produce brushless sound. However, the quality of the latter is not so great, and I would prefer to use libfdk_aac.