<p>General speaking, you can not split already encoded video into some chunks with arbitrary length without re-encoding.</p>

<p>The simplest way to make a cut is to get content between IDR frames. You could split your video sequence into segments that contain arbitrary number of GOPs (sequence of frames starting with IDR frame with length to next IDR) each. In this case, you could just copy the content without re-encoding.</p>

<p>So, you goal is to find out appropriate IDR frames, that satisfy you clip duration, and make a cut with copy. You lucky <code>ffmpeg</code> use <code>-noaccurate_seek</code> for copy. You could point start position by <code>-ss</code> and duration with <code>-to</code> near IDR.</p>

<p>You could face some challenges here:</p>

<ol>
<li>original video sequence has a variable GOP length - clip duration
won't be the same; </li>
<li>original video sequence has an infinite GOP
length (only first frame is IDR) - impossible to split it without re-encoding;</li>
</ol>

<p>In your example you should move <code>-ss</code> and <code>-to</code> options before <code>-i</code>, because you want to seek start position in the input video.</p>

CC BY-SA 4.0
2018-12-07T09:43:46.990Z
Moving `-ss` and `-to` options before `-i` throws an error:
`ffmpeg -y -ss 0:00:16.10 -to 0:00:19.11 -i ./file.mkv -acodec copy -vcodec copy -loglevel error 'raw/output.mkv'`: Option to (record or transcode stop time) cannot be applied to input url ./file.mkv -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Édouard Lopez
CC BY-SA 4.0
2018-12-05T05:07:02.157Z
2018-12-05T05:07:02.157Z
PRu
<p>I'm trying to split a video (50-100Mo) into several small clips of a few seconds each. I don't need re-encoding, hence my use of <code>codec copy</code>.</p>

<p>However some of the resulting clips don't have any video.</p>

<h3>Fast but no video in some files</h3>

<pre><code>ffmpeg \
  -y \
  -i ./data/partie-1:-Apprendre-300-mots-du-quotidien-en-LSF.jauvert-laura.hd.mkv \
  -ss 0:00:07.00 \
  -codec copy \
  -loglevel error \
  -to 0:00:10.36 \
  'raw/0:00:07.00.au revoir.mkv'
</code></pre>

<p>I also tried <code>-map 0 -c copy</code>, <code>-acodec copy -map 0:a -vcodec copy -map 0:v</code> or no option related to codec.</p>

<h3>Slow but complete</h3>

<p>No argument related to audio/video encoding, it's working but pretty slow.</p>

<pre><code>ffmpeg -y \
  -i "$SOURCE_VIDEO_FILE" \
  -ss 0:05:37.69 \
  -to 0:05:40.64 \
  -loglevel error
  'raw/0:05:37.69.pas la peine.mkv'
</code></pre>

<h3>Question</h3>

<p>How do I split a video into small chunk <code>~2-4s</code> when I have no need for re-encoding?</p>

<ffmpeg><encoding><linux>
How to split video in small clip?
Édouard Lopez
# How to split video in small clip?

(Asked by: username_0 on 2018-12-02)

I'm trying to split a video (50-100Mo) into several small clips of a few seconds each. I don't need re-encoding, hence my use of codec copy.
However some of the resulting clips don't have any video.
Fast but no video in some files
ffmpeg \
  -y \
  -i ./data/partie-1:-Apprendre-300-mots-du-quotidien-en-LSF.jauvert-laura.hd.mkv \
  -ss 0:00:07.00 \
  -codec copy \
  -loglevel error \
  -to 0:00:10.36 \
  'raw/0:00:07.00.au revoir.mkv'

I also tried -map 0 -c copy, -acodec copy -map 0:a -vcodec copy -map 0:v or no option related to codec.
Slow but complete
No argument related to audio/video encoding, it's working but pretty slow.
ffmpeg -y \
  -i "$SOURCE_VIDEO_FILE" \
  -ss 0:05:37.69 \
  -to 0:05:40.64 \
  -loglevel error
  'raw/0:05:37.69.pas la peine.mkv'

Question
How do I split a video into small chunk ~2-4s when I have no need for re-encoding?

**Tags:** ffmpeg, encoding, linux


---

## 1 answers

### Answer by username_1 on 2018-12-05. Score: 1 | Accepted answer

General speaking, you can not split already encoded video into some chunks with arbitrary length without re-encoding.

The simplest way to make a cut is to get content between IDR frames. You could split your video sequence into segments that contain arbitrary number of GOPs (sequence of frames starting with IDR frame with length to next IDR) each. In this case, you could just copy the content without re-encoding.

So, you goal is to find out appropriate IDR frames, that satisfy you clip duration, and make a cut with copy. You lucky `ffmpeg` use `-noaccurate_seek` for copy. You could point start position by `-ss` and duration with `-to` near IDR.

You could face some challenges here:

1. original video sequence has a variable GOP length - clip duration
   won't be the same;
2. original video sequence has an infinite GOP
   length (only first frame is IDR) - impossible to split it without re-encoding;

In your example you should move `-ss` and `-to` options before `-i`, because you want to seek start position in the input video.

> **Comments:**
> **username_0**: Moving `-ss` and `-to` options before `-i` throws an error: `ffmpeg -y -ss 0:00:16.10 -to 0:00:19.11 -i ./file.mkv -acodec copy -vcodec copy -loglevel error 'raw/output.mkv'`: Option to (record or transcode stop time) cannot be applied to input url ./file.mkv -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.  

---

