Answers.Body: <p>The issue with the frames are very likely the results of using h264 and not re-encoding the video. h264 usually doesn't have single frames (unless encoded with an intra profile) but groups of frames (GOPs), ffmpeg will cut at a keyframe position ie. at the end or beginning of a GOP. Or not in the case of your first approach, giving you issues with the affected GOPs.</p>
  
  <p>The issue should be resolved by re-encoding (-vcodec libx264 -preset slow) or if that also yields errors transcode to a lossless codec like jpeg2000 (<code>-vcodec libopenjpeg</code>) cut your video and then encode into h264 again (or any other codec you may prefer).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-23T11:37:28.357Z
Answers.Text: What about using -g parameter?! (set GOP size)
Answers.UserDisplayName: Dr.jacky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-23T19:35:24.390Z
Answers.Text: That wouldn't help you with frame accurate cutting. The issue is that there are GOPs. if you split a video within a GOP you will destroy frames at the end of your clip.
Answers.UserDisplayName: timonsku
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T03:20:52.710Z
Answers.Text: What do you mean by "you will destroy frames at the end of your clip" ?!
Answers.UserDisplayName: Dr.jacky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T19:33:40.803Z
Answers.Text: Frames inside a GOP need all the other frames in the GOP, so if you cut a GOP the frames that are left don't have all the needed information. Technically you could re-encode just the last GOP but I don't think there is a tool that would do this for you.
Answers.UserDisplayName: timonsku
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T19:35:57.870Z
Answers.Text: See: https://en.wikipedia.org/wiki/Group_of_pictures
Answers.UserDisplayName: timonsku
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-12T19:53:49.203Z
Answers.LastActivityDate: 2014-10-12T19:53:49.203Z
Answers.UserDisplayName: timonsku
Body: <p>I am currently using ffmpeg to split videos into <code>10</code> seconds segments. I have taken two approaches but neither seems to yield the desired results. Approach number one is using basic cutting with the -t and -ss options to get the segments. This gives close to accurate segments but  it has some issues with the frames in the ending of some videos. The second option is using segment: great and fast but it gives segments of not equal duration. Any idea how to get segments of the same duration and no issues in the frames? In other words if I play them in a list it should play smoothly</p>
  
  <p>General way</p>
  
  <pre><code>ffmpeg – i input.mp4  -ss &lt;start&gt; -t &lt;duration&gt; -vcodec copy -acodec copy output%03d.mp4
  </code></pre>
  
  <p>Using segment</p>
  
  <pre><code>ffmpeg -i input.mp4 -c copy -map 0 -segment_time 8 -f segment output%03d.mp4
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-23T11:42:16.710Z
Comments.Text: Did you find any solution or reason?
Comments.UserDisplayName: Dr.jacky
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-06T22:37:56.800Z
Comments.Text: the -g 1 parameter will help with frame cutting making sure are just individual frames...this encoding is known as intra encoding....but the video quality will be much worse and the file will be much larger.
Comments.UserDisplayName: pet
Tags: <video><video-editor><ffmpeg>
Title: Split video into equal duration segments
UserDisplayName: Code_Ed_Student
ThreadText: # Split video into equal duration segments
  
  (Asked by: username_0 on 2014-10-11)
  
  I am currently using ffmpeg to split videos into `10` seconds segments. I have taken two approaches but neither seems to yield the desired results. Approach number one is using basic cutting with the -t and -ss options to get the segments. This gives close to accurate segments but it has some issues with the frames in the ending of some videos. The second option is using segment: great and fast but it gives segments of not equal duration. Any idea how to get segments of the same duration and no issues in the frames? In other words if I play them in a list it should play smoothly
  
  General way
  
  ```
  ffmpeg – i input.mp4  -ss <start> -t <duration> -vcodec copy -acodec copy output%03d.mp4
  
  ```
  
  Using segment
  
  ```
  ffmpeg -i input.mp4 -c copy -map 0 -segment_time 8 -f segment output%03d.mp4
  
  ```
  
  **Tags:** video, video-editor, ffmpeg
  
  > **Comments:**
  > **username_1**: Did you find any solution or reason?  
  > **username_2**: the -g 1 parameter will help with frame cutting making sure are just individual frames...this encoding is known as intra encoding....but the video quality will be much worse and the file will be much larger.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2014-10-12. Score: 2 | Accepted answer
  
  The issue with the frames are very likely the results of using h264 and not re-encoding the video. h264 usually doesn't have single frames (unless encoded with an intra profile) but groups of frames (GOPs), ffmpeg will cut at a keyframe position ie. at the end or beginning of a GOP. Or not in the case of your first approach, giving you issues with the affected GOPs.
  
  The issue should be resolved by re-encoding (-vcodec libx264 -preset slow) or if that also yields errors transcode to a lossless codec like jpeg2000 (`-vcodec libopenjpeg`) cut your video and then encode into h264 again (or any other codec you may prefer).
  
  > **Comments:**
  > **username_1**: What about using -g parameter?! (set GOP size)  
  > **username_3**: That wouldn't help you with frame accurate cutting. The issue is that there are GOPs. if you split a video within a GOP you will destroy frames at the end of your clip.  
  > **username_1**: What do you mean by "you will destroy frames at the end of your clip" ?!  
  > **username_3**: Frames inside a GOP need all the other frames in the GOP, so if you cut a GOP the frames that are left don't have all the needed information. Technically you could re-encode just the last GOP but I don't think there is a tool that would do this for you.  
  > **username_3**: See: https://en.wikipedia.org/wiki/Group_of_pictures  
  
  ---
  
  