title: Converting AAC stream to DASH MP4 with high fragment length precision
body: <p>For my HTML5 project I need to create a fragmented MP4 file with a single audio stream (no video), each fragment of which has a duration of exactly 0.1 second.</p>
  
  <p>Accordingly to ffmpeg docs, you can accomplish that by passing a value in microseconds with '-frag_duration' - which I found to be working and playable with HTML5 MediaSource API:</p>
  
  <pre><code>$ ffmpeg -y -i input.aac -c:a libfdk_aac -b:a 64k -level:v 13 -r 25 -strict experimental -movflags empty_moov+default_base_moof -frag_duration 100000 output.mp4
  </code></pre>
  
  <p>As we have a 210 second audio split up by 0.1s fragments, I expect that in output.mp4 we'd have 2100 fragments, hence 2100 moof atoms. But, upon inspecting it I've figured out that we only have 1811 moof atoms - which means that some (or maybe even all) fragments are bigger than expected:</p>
  
  <pre><code>$ python ~/git/mp4viewer/src/showboxes.py output.mp4 |grep moof|wc -l
  1811
  </code></pre>
  
  <p>Could anybody tell me what's wrong, and how could I accomplish what I want?</p>
  
  <p>Right now my assumption is that during an encoding I have AAC frame length which is not a multiple of 0.1s, hence ffmpeg has no chance to produce the fragments that are strictly equal to 0.1s but I'm not sure. If somebody can confirm that - and let me know a way to explicitly set AAC frame_size in FFMPEG (I couldn't find anything like that in the docs), or completely disprove this - it would be also highly appreciated.</p>