user6054: I'm producing several versions of a clip (320x180 24 fps and aprox 2Mbps) compressed with h.264 with ffmpeg using Avanti. Each version has different framerate.
The video output has a slightly different duration than source:
source - 24 fps - 01:52
10 fps - 01:53
5 fps - 01:53
1 fps - 01:56
0.5 fps - 02:04

Results are the same if use Handbrake.
Why is this happening? I'm aware that there are several kind of frames in h.264, what is then ffmpeg doing when I set framerate? Is it setting keyframe interval?

user2836: My best guess is that this is due to the length of a group of pictures.  h.264 streams are composed of 3 different types of frames.  I frames, which contain the full frame, P frames which contain the information that has changed since the previous frame and B frames which are bi-directional and contain information about the changes between previous and future frames.
These frames are used in a fixed order that is repeated.  That repeated set is known as a group of pictures.  Typical GOP lengths are generally somewhere around 15 frames.  At 15 or more FPS, you'll always finish your GOP within one second.  At half a frame per second though, it can take up to 7 seconds after your last normal frame for the GOP to finish.
That still doesn't seem to fully explain your 12 extra seconds, but it is possible you are using a longer GOP.  I can't think of any other potential causes.
It is also worth noting that under the hood, Handbrake is just a UI for other encoding libraries, one of which is FFMPEG, so that may also help explain the consistent behavior as well.

6054: <p>I'm producing several versions of a clip (320x180 24 fps and aprox 2Mbps) compressed with h.264 with ffmpeg using Avanti. Each version has different framerate.
The video output has a slightly different duration than source:</p>

<pre><code>source - 24 fps - 01:52
10 fps - 01:53
5 fps - 01:53
1 fps - 01:56
0.5 fps - 02:04
</code></pre>

<p>Results are the same if use Handbrake.
Why is this happening? I'm aware that there are several kind of frames in h.264, what is then ffmpeg doing when I set framerate? Is it setting keyframe interval?</p>
 2836: <p>My best guess is that this is due to the length of a group of pictures.  h.264 streams are composed of 3 different types of frames.  I frames, which contain the full frame, P frames which contain the information that has changed since the previous frame and B frames which are bi-directional and contain information about the changes between previous and future frames.</p>

<p>These frames are used in a fixed order that is repeated.  That repeated set is known as a group of pictures.  Typical GOP lengths are generally somewhere around 15 frames.  At 15 or more FPS, you'll always finish your GOP within one second.  At half a frame per second though, it can take up to 7 seconds after your last normal frame for the GOP to finish.</p>

<p>That still doesn't seem to fully explain your 12 extra seconds, but it is possible you are using a longer GOP.  I can't think of any other potential causes.</p>

<p>It is also worth noting that under the hood, Handbrake is just a UI for other encoding libraries, one of which is FFMPEG, so that may also help explain the consistent behavior as well.</p>
