How to Make Automatic Supercuts
I’ve been working on some long-needed updates to Videogrep, my command-line tool that automatically generates supercuts. These updates were motivated in part by a 10 week class I recently developed and taught at the School for Poetic Computation called Scrapism (web-scraping-as-art). The class includes a section on automatically manipulating video, and I’ll also be teaching this material this June, in a 3-hour workshop that is specifically about video and the command line at Sonic Acts.
The most significant improvement I’ve made to the software is migrating Videogrep’s offline transcription tool from Pocketsphinx, which is notoriously inaccurate and seemed to have stopped working on my Mac, to Vosk, which anecdotally works around 1000% better.
I’ve also attempted to simplify the tool a bit, removing some features that I don’t think anyone was really using, like searching by part of speech or word category.
In this tutorial I’ll walk you through how to use the new and improved Videogrep, as well as another tool called yt-dlp that allows you to download videos from almost any website.
Prerequisites
This tutorial requires some familiarity with the command line (although not much). If you’re brand new to this type of thing, you may wish to take a look at this video/write-up I’ve prepared: Intro to the Command Line.
You’ll also need Python installed on your computer. If you’re on a Mac you should already be good to go. If you’re on a PC, download and install the latest stable release of Python here.
Downloading videos with yt-dlp
Before we get into Videogrep, here’s a brief intro to yt-dlp
.
yt-dlp
allows you to very easily download almost any video from the web. To install it, just run:
There are tons of things you can do with yt-dlp
. I’m just going to cover the basics here, focusing on what I find the most useful for making supercuts.
Basic usage
To download a video, just type yt-dlp
and the URL of the video you want. This will work for YouTube, Vimeo, Twitter and hundreds of other websites. For example, if we want to download some highlights from the nightmarish Metaverse announcement video (which I’ll be using later to demo Videogrep
), it’s as easy as:
yt-dlp "https://www.youtube.com/watch?v=gElfIo6uw4g"
Note: I’ve surrounded the video URL in quotes to avoid problems that can occur if the URL contains special characters. This isn’t always necessary, but I usually do it anyway.
You can also download an entire user, channel, playlist, or search query. For example this will download the entire White House channel (it will take a long time).
yt-dlp "https://www.youtube.com/user/whitehouse/"
And this will download videos matching the search query “capitalism:”
yt-dlp "https://www.youtube.com/results?search_query=capitalism"
You can pretty much give yt-dlp any URL on YouTube, or any other video site.
File formats
Websites like YouTube and Vimeo store videos in multiple file formats and sizes. By default, yt-dlp
will download the highest quality video it can find, but frequently I like to work with smaller videos. To get a list of all available video formats simply add the -F
option:
yt-dlp "https://www.youtube.com/watch?v=gElfIo6uw4g" -F
You’ll see something like this:
You can then select a file to download by passing the -f
option along with an id (the number or characters in the first column). So if I want to download this video as a 1280×720 mp4, I would type:
yt-dlp "https://www.youtube.com/watch?v=gElfIo6uw4g" -f 22
Note: some formats are video or audio only.
Changing the video filename
By default yt-dlp
will automatically name the downloaded video for you. This is useful, but sometimes it’s convenient to name the file yourself. To do so, add the -o
flag.
yt-dlp "https://www.youtube.com/watch?v=gElfIo6uw4g" -o meta.mp4
Download subtitles
Finally, YouTube usually provides auto-generated subtitles for videos. These are fairly high quality, and are useful for a variety of reasons, including making supercuts!
To download subtitles, just add --write-auto-sub
.
yt-dlp "https://www.youtube.com/watch?v=gElfIo6uw4g" --write-auto-sub
You can also combine this with -f
, and -o
, like so:
yt-dlp "https://www.youtube.com/watch?v=gElfIo6uw4g" --write-auto-sub -f 22 -o meta.mp4
This will download the video a