title: Cut a video in between key frames without re-encoding the full video using ffpmeg?
body: <p>I would like to cut a video at the beginning at any particular timestamp, and it need to be <strong>precise</strong>, so the nearest key frame is not good enough.</p>
  <p>Also, these videos are rather long - an hour or longer - so I would like to <strong>avoid re-encoding</strong> this altogether if possible, or otherwise only re-encode a minimal fraction of the total duration. Thus, would like to maximise the use of <code>-vcodec copy</code>.</p>
  <p>How can I accomplish this using <code>ffmpeg</code>?</p>
  <p>NOTE: See scenario, and my own rough idea for a possible solution below.</p>
  <hr />
  <p>Scenario:</p>
  <ul>
  <li>Original video
  <ul>
  <li>Length of 1:00:00</li>
  <li>Has a key frame every 10s</li>
  </ul>
  </li>
  <li>Desired cut:
  <ul>
  <li>From 0:01:35 through till the end</li>
  </ul>
  </li>
  <li>Attempt #1:
  <ul>
  <li>Using <code>-ss 0:01:35 -i blah.mp4 -vcodec copy</code>, what results is a file where:</li>
  <li>audio starts at 0:01:30</li>
  <li>video also starts at 0:01:30</li>
  <li>this starts both the audio and the video too early</li>
  </ul>
  </li>
  <li>using <code>-i blah.mp4 -ss 0:01:35 -vcodec copy</code>, what results is a file where:
  <ul>
  <li>audio starts at 0:01:35,</li>
  <li>but the video is blank/ black for the first 5 seconds,
  <ul>
  <li>until 0:01:40, when the video starts</li>
  </ul>
  </li>
  <li>this starts the audio on time,
  but the video starts too late</li>
  </ul>
  </li>
  </ul>
  <hr />
  <p>Rough idea</p>
  <ul>
  <li>(1) cut 0:01:30 to 0:01:40
  <ul>
  <li>re-encode this to have new key frames,
  including one at the target time of 0:01:35</li>
  <li>then cut this to get the 5 seconds from 0:01:35 through 0:01:40</li>
  </ul>
  </li>
  <li>(2) cut 0:01:40 through till the end
  <ul>
  <li>without re-encoding, using <code>-vcodec copy</code></li>
  </ul>
  </li>
  <li>(3) <code>ffmpeg concat</code> the first short clip (the 5 second one)
  with the second long clip</li>
  </ul>
  <p>I know/ can work out the commands for (2) and (3), but am unsure about what commands are needed for (1).</p>