Sub topic 4
Cutting out mistakes
This chapter covers how to remove a mistake from a lecture recording, both in an editor and with ffmpeg. It assumes you can open a project in a timeline editor, you know what the playhead is, and you have already marked the mistakes and pauses you want to remove. You should also be comfortable running a command in a terminal.
What a cut really does
A cut removes a span of time from the finished video. Most editors never touch your original file. They store a list of instructions: "play file A from 0:00 to 1:12, then from 1:20 to the end." Deleting a segment edits that list, which is why the work stays non-destructive.
Every cut has two edges:
- The in point is where the removed section starts.
- The out point is where it ends.
Everything between them disappears, and the material after the out point moves earlier in time to close the gap. The closing of the gap is the main source of errors, because audio, video, captions, and any zoom you have planned are all affected by it.
Three ways to remove a section
Editors give you several tools. They produce the same result in different ways.
| Operation | What it does | Gap left? | Typical use |
|---|---|---|---|
| Split (razor) | Divides one clip into two at the playhead. Nothing is removed yet. | No | Marking the in and out points |
| Delete | Removes the selected clip and leaves empty space. | Yes | When other tracks must stay aligned |
| Ripple delete | Removes the clip and shifts everything after it earlier. | No | Normal removal of mistakes |
For a lecture with a single main video track, ripple delete is the usual choice. Use plain delete only when something else, such as a separate screen recording, must stay at its original position.
A workflow for one cut in an editor
- Place the playhead just before the mistake and split the clip.
- Move the playhead to the first usable moment after the mistake and split again.
- Select the middle piece, which holds only the mistake.
- Ripple delete it.
- Play across the join, starting a few seconds before it.
Step 5 matters most. Judge a cut by listening to it at normal speed. A cut that looks clean on the timeline can still clip the end of a word or leave a breath that sounds odd.
Choosing good edit points
- Cut in silence between words, not in the middle of a sound. Zoom the timeline in until you can see the audio waveform, and place the split where the waveform is flat.
- Leave about 0.2 to 0.4 seconds of room around speech. Cutting flush against a word makes it sound clipped.
- When the speaker restarts a sentence ("The codec is... the container is a wrapper"), keep the better take and remove the whole false start, not just the first word.
- Avoid cutting during a gesture or a cursor movement on screen. The cursor will appear to jump.
Cutting with ffmpeg
An editor is best for judging where to cut. ffmpeg is useful when you already know the times and want a repeatable result. The first example removes the section from 72 s to 80 s from both video and audio.
ffmpeg -i lecture.mp4 \
-vf "select='not(between(t,72,80))',setpts=N/FRAME_RATE/TB" \
-af "aselect='not(between(t,72,80))',asetpts=N/SR/TB" \
lecture_cut.mp4The command works in two parts on each stream.
selectandaselectkeep only the frames or audio samples for which the expression is true. Here,between(t,72,80)is true for times from 72 to 80 seconds, andnot(...)inverts it. Everything outside that window is kept.setptsandasetptsrewrite the timestamps. Without them, the kept frames would keep their original times, leaving a gap at 72 s. Players would then freeze or drift out of sync. The expressionsN/FRAME_RATE/TBandN/SR/TBnumber the kept frames or samples in order, so playback is continuous.
You must apply the same cut to both streams. If you cut only the video, the audio is now 8 seconds longer and the picture and voice no longer match.
Removing several sections
To remove more than one span, join conditions with +, which acts as a logical "or" in ffmpeg expressions.
ffmpeg -i lecture.mp4 \
-vf "select='not(between(t,72,80)+between(t,140,146.5))',setpts=N/FRAME_RATE/TB" \
-af "aselect='not(between(t,72,80)+between(t,140,146.5))',asetpts=N/SR/TB" \
lecture_cut2.mp4Times refer to the original recording. You do not need to adjust the second span for the first cut, because both are measured against the input.
Keeping a single part
To keep only one part, for example to trim the start and end, use -ss and -t before the input. This also seeks quickly. The zoom example later in this tutorial uses the same pattern.
ffmpeg -ss 20 -t 10 -i lecture.mp4 -c:v libx264 -c:a aac segment.mp4Why this re-encodes
The select approach decodes every frame and writes new ones, so the video is re-encoded. That gives frame-accurate cuts, but it takes longer and loses a little quality with each generation. Cutting without re-encoding is possible with -c copy, but the video can then only start on a keyframe, a full picture that the following frames depend on. A copy-mode cut may land a second or more away from your chosen time. A later chapter explains keyframes in detail.
| Method | Accuracy | Speed | Quality effect |
|---|---|---|---|
| `select` filter (re-encode) | Frame accurate | Slower | Small loss per re-encode |
| `-c copy` (stream copy) | Snaps to keyframes | Very fast | None |
For a lecture you will also zoom and caption, you re-encode anyway. Do all edits in one pass or from the original file so you do not stack losses.
Common errors
- Audio drifts after the cut. You cut one stream only, or you removed
setptsorasetpts. Apply the same cut to both and regenerate both sets of timestamps. - The video freezes for several seconds. Timestamps still contain the gap. Add
setpts=N/FRAME_RATE/TB. - A word is clipped at the join. The edit point is too close to speech. Move it into the silence and leave a short margin.
- The cut is a second or more off. You used stream copy, so it snapped to a keyframe. Re-encode for accuracy.
- Captions no longer match. Captions made before the cut keep their old times. Create or time captions after the cuts are final.
- Wrong section removed. Times in the ffmpeg command refer to the original file, not to a version you have already cut. Check that each time comes from the same source.
Checking the result
Check the cut in three steps. First, play 5 seconds before and after each join at normal speed and listen for clipped words. Second, compare the total duration with your expectation. Removing 8 seconds from a 600-second lecture should give about 592 seconds. Third, you can read the duration with ffprobe.
ffprobe -v error -show_entries format=duration \
-of default=noprint_wrappers=1:nokey=1 lecture_cut.mp4If the audio and video streams report different lengths, the sync is off. Re-run the cut with both filters set identically.
Practical habits
- Work from the end of the recording back to the start. Cutting a late section first does not shift the times of earlier mistakes, so your notes stay valid.
- Keep a text list of the cuts with their start and end times. It lets you rebuild the edit with ffmpeg later.
- Save the project before you export, and keep the original recording untouched.
Exercise
A lecture is 600 seconds long. You remove the spans 72–80 s and 140–146.5 s with the ffmpeg select filter, but you forget asetpts on the audio. What is the expected length of the correct result, and what problem would you hear?
Show answer
The correct result is 600 − 8 − 6.5 = 585.5 seconds. Without asetpts, the audio keeps its original timestamps and leaves gaps where the cuts were, so the audio would go silent or drift out of sync with the picture after the first cut.
Exercise
You need a cut at exactly 95.4 s, and you plan to use -c copy for speed. Why might the result start at a different time, and what change fixes it?
Show answer
With stream copy, the video can only begin at a keyframe, so the cut snaps to the nearest one, which may be a second or more away. Re-encode the video, for example with -c:v libx264, to get a frame-accurate cut.