The problem#
Sometimes I have a long video that I only want a shorter section of. Maybe it's a TV show that I want to clip a funny scene out of. Or a video of a concert that I want to clip the individual songs out of so I can put them into my music library. But figuring out exactly where to start and end the clip so there's no weird sounds or flashes due to accidentally including the surrounding video takes some care.
The solution#
In order to determine the right clip location, I wanted an easy way to repeatedly watch and listen to the start or end of a proposed clip and get immediate feedback on adjusting its position frame-by-frame.
find_split
is a script that implements this workflow.
You give it a video, a proposed frame index to split the video on, a
preview context length in number of frames, and whether the preview
should be the video before (to the left of) or after (to the right of)
the split. It plays the preview window ending or starting at the
proposed split and waits for the user to press a key indicating how to
move the proposed split and then repeats, starting by playing that preview.
Once you've confirmed you've determined the desired frame index, press
` (or just Ctrl+c) to exit.
The full keyboard controls are described at the link.
$ ./find_split video.mkv 1000 60 left
Playing video.mkv on left of split at 1000 \(with 60 extra frames\).
Playing video.mkv on left of split at 1060 \(with 60 extra frames\).
The second line appears after typing Shift+h to increase the proposed frame index by 60 after the first clip finishes. That means the second clip played will be from frame 1000 to frame 1060, so about two seconds (60 frames) long starting at approximately 33 seconds into the video. You can continue to adjust the position until you've decided you've determined the correct frame.
Once you have found the start and end frames (here 1060
to 2034
),
you can save the clip to a file:
$ ./encode_frames video.mkv 1060 2034 clip.mkv av
(Change the av
to audio
if you only want the audio and not the video.)