As a weekend project, I decided to delve into some python and opencv to automate creating clips of twitch streamer LilAggy getting hit in Elden Ring over many, many hours of his streams, with the goal of creating a supercut.
I don't use python very often so this was a fun challenge. To detect hits, I analyzed the pixels of the player's health bar, which is always in the same place on screen. I used a fairly low resolution download of the vods, as they're very long. When your health decreases, the subtracted health turns from red to yellow in the bar, and then fades out. Therefore, detecting hits is as easy as detecting a lot of pixels turning from red to yellow in a single frame. When I detected this, I saved the timecode of the hit, and continued analysis of the vod. Then I downloaded a full-quality clip starting 3 seconds before each hit event and ending 3 seconds after.
There were a fair number of false positives, like when red or yellow objects moved behind the health bar, but it was easy to review each clip manually. Unfortunately I probably missed a lot of hits, as if the damage is very small the yellow health does not appear. I couldn't think of any other reliable ways to detect hits precisely (Aggy updates the hit counter manually and sometimes does it minutes after the hit takes place, so scanning that would not work). I'm okay with that though, as I still got hundreds of great hit clips that I was able to combine into the supercut!
The source code is available here on my GitHub.