Detecting episode transitions in a video
A few days ago I downloaded a few large files that contain a bunch of Tom & Jerry episodes stitched together. The duration of each file is north of one hour. Since I don't watch the whole thing in a single sitting, I find myself having to perform a dance of fast forwarding to where I left off, accidentally overshoot, then go backwards before being able to properly resume the video. I was wasting precious time that should instead be exploited in doom scrolling. I decided to take matters into my own hands... ffmpeg to the rescue The first thing I noticed was that the screen fades to black between episodes of the same file. My first reflex was to somehow detect this, and split the large video file based on black screens. This heuristic turned out to be an actual thing, because ffmpeg already supports it with a filter called blackdetect . I didn't have to write any code for this part. ffmpeg spits out start and end offsets for the black screens, along with a bunch of irr...