Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-11T20:25:16.997Z
Answers.Text: I don't know the mechanics of it (how ffmpeg handles it), but you can encode using a 'closed GOP' structure or an unclosed one. If you opt that every GOP is closed, the last GOP may be padded out to its native length. In some situations it's mandatory to end with a closed GOP, so this may be the default here.
Answers.UserDisplayName: Jim Mack
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T08:19:14.803Z
Answers.Text: I've realized that there is somewhat of "starting offset", i.e. video starts with black and there is a soft transition to an image of earth from space, if first non-black frame is aprox at 00:03 in source video, it does not appear until 00:23 in 0.5 fps version and its content come from a frame from 00:04. Maybe this confirms the "GOP-completness theory"... I will do more tests.
Answers.UserDisplayName: jmm
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T10:34:35.903Z
Answers.Text: I've performed more tests and GOP size has apparently nothing to do whith my problem. I set -g 0 that, according to https://ffmpeg.org/ffmpeg.html (section 6. Tips), means an all I-frames video and keep getting extra seconds in output.
Answers.UserDisplayName: jmm
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T13:02:09.130Z
Answers.Text: @jmm that's unfortunate. I'm out of other ideas.
Answers.UserDisplayName: AJ Henderson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-11T17:35:00.307Z
Answers.LastActivityDate: 2014-06-11T17:35:00.307Z
Answers.UserDisplayName: AJ Henderson
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-11T17:34:12.233Z
Comments.Text: How are you measuring the input and output durations? Also, without your actual `ffmpeg` commands and the complete console outputs it is impossible to provide an accurate answer.
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-12T08:11:34.020Z
Comments.Text: I'm using Avanti, so I'm not sure of all the actual ffmpeg commands it uses internally, but I am only selecting codec, container, frame size, frame rate and bitrate.
Comments.UserDisplayName: jmm
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-12T08:21:01.883Z
Comments.Text: I'm getting durations from player information and from how long does it actually take the player complete reproduction.
Comments.UserDisplayName: jmm
Tags: <ffmpeg>
Title: Output file longer than source with ffmpeg
UserDisplayName: jmm
ThreadText: # Output file longer than source with ffmpeg
  
  (Asked by: username_0 on 2014-06-11)
  
  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?
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: How are you measuring the input and output durations? Also, without your actual `ffmpeg` commands and the complete console outputs it is impossible to provide an accurate answer.  
  > **username_0**: I'm using Avanti, so I'm not sure of all the actual ffmpeg commands it uses internally, but I am only selecting codec, container, frame size, frame rate and bitrate.  
  > **username_0**: I'm getting durations from player information and from how long does it actually take the player complete reproduction.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-06-11. Score: 1
  
  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.
  
  > **Comments:**
  > **username_3**: I don't know the mechanics of it (how ffmpeg handles it), but you can encode using a 'closed GOP' structure or an unclosed one. If you opt that every GOP is closed, the last GOP may be padded out to its native length. In some situations it's mandatory to end with a closed GOP, so this may be the default here.  
  > **username_0**: I've realized that there is somewhat of "starting offset", i.e. video starts with black and there is a soft transition to an image of earth from space, if first non-black frame is aprox at 00:03 in source video, it does not appear until 00:23 in 0.5 fps version and its content come from a frame from 00:04. Maybe this confirms the "GOP-completness theory"... I will do more tests.  
  > **username_0**: I've performed more tests and GOP size has apparently nothing to do whith my problem. I set -g 0 that, according to https://ffmpeg.org/ffmpeg.html (section 6. Tips), means an all I-frames video and keep getting extra seconds in output.  
  > **username_2**: @username_0 that's unfortunate. I'm out of other ideas.  
  
  ---
  
  