Periodicity of a Music Video


I'm hoping this particular entry functions as a way to introduce my approach to starting a project.

Background

I can already hear it: "what in the world does that title even mean? Sure it 's got something to with music videos and 'periodicity ' but that doesn't explain anything! "
And that is absolutely correct! Without a doubt. I just thought it was a relatively catchy way to put what I'm trying to do into some words.
Essentially, I want to be able to extract information about the beats per minute of a music video without the music -- the "without " is the important part here.

Here's one of the things from which I originally got the inspiration:

(Hmm, this didn't load properly. Here is the link to the tiktok anyway.)

As you can see, it's something relatively dumb, but it's worth a challenge and worth the shot. And often times, that does end up being the case with various projects. It's you going "huh can I make a computer do this? "

When approaching projects to undertake, don't disregard something because it feels like a "dumb idea " or because it feels like it might be too simple or not of use in a commercial setting. That's simply not the point of these projects. The point is to expand your capabilities as an engineer when it comes to problem solving and approaching new ideas.
The projects do not have to be all encompassing -- nor do they have to be super complex to constitute experience. Heck, a decent amount of experience is going to come from working on a variety of different things -- and though it might not quite seem like it as you work on the projects, they ultimately will be helping build your depth of knowledge that you can draw from.


The second thing I'm sure you're wondering is: "Is this even something that is doable? " Sure as a person you can sort of intuitively see that these songs are both in the same BPM, but is that something that you can programmatically find?

The answer is always yes, even when the answer is no. Our programs have the ability to see (using cool libraries like OpenCV), hear (using frequency analysis tools), and some of them can even feel and taste. So, in my humblest of opinions, you should definitely always assume that you can, even if you aren't sure.

However, as you begin to work on more and more projects you will find that often times things are tangentially related to other things -- and you can draw on that depth of experience to quickly determine whether or not something is capable of being done. But until you learn otherwise, you simply have to assume that it is.

Like for example (as seen below), for this particular project idea, I already knew OPENCV had an optical flow tool that could potentially be of use.


But, it is never worth dismissing a topic idea simply because you don't know if it can be done because a lot of the learning comes from figuring out whether or not it can be done.

Thirdly, now that I'm assuming it can be done... "how do I even begin to think up how to do it? Sure you say to assume it can be done but that doesn 't mean I know anything about how to do it."

Well, yeah that's kind of where the fun starts. I mean, this is the real meat and potatoes of what you do as an engineer. You have been given a certain problem and now you have to sort of figure out how it ticks, and how to make it bend to your will, really. As cliche as it might be you really do have to approach it "like a computer."

Certainly, yes we as people can see things "intuitively" but (for now) that really doesn't mean much to a computer. There needs to be something that can be turned into numbers, something that can -- in some way, shape, or form -- be analyzed as a distinct value.

For this particular problem I would need to recognize two things. One, what constitutes a beat? Is there something specific that is associated with a beat of music -- something present throughout most of my testing selection? And two, is it something that I can empirically analyze?

Well, yeah. Every time a beat occurs it looks like they move in some way -- though we cannot exactly predict how they move, we can definitely say they do move.

Okay, well can that be used to determine the BPM? Yeah, sure if we are able to look at the movements of the dancers in a holistic approach and sort of graph when they move versus when they're still we might be able to visually determine whether the beats of music. ( And remember, you have to assume anything you can visually determine the computer can as well!)

Well, now we have something we can work off of. Earlier if we were to Google "how to find the BPM of a video" we would not find much that actually related -- most of it would be with regards to finding the BPM of the music in the video but not actually about the video itself as we can see below.

But now, with the addition of another simple keyword -- "opencv" -- we can find far more pertinent results that help to drive us closer to a solution. We went from not having any idea whether or not something was possible to having some code that we can play around with.

This brings us to another really important portion of working on projects -- research. The ability to use Google is going to be one of the main key factors between succeeding in doing research and spending time in a tailspin. If you cannot properly parse what keywords are needed, you will find yourself stumbling around A LOT.

For one, have a good general idea of what basic libraries and imports are available to you. I use Python for a vast majority of my "just to learn" projects which means I have to have an understanding of some of the more common libraries: Simply throwing in one of these libraries can DRASTICALLY improve search results. A lot of the websites that want to teach you to "improve your Google Fu" will say you should add +'s or -'s to the end of your search terms, or use the * wildcard feature, or use AROUND(20) to search for relative closeness BUT these will not help if Google is not properly searching using your keywords.

This is slightly a personal opinion but often times the last place I search is videos. Yes, certainly Youtube videos are a good place to learn things conceptually, but I find that videos are not the best place to learn things practically. So rather, I would recommend looking through blogs and tutorials instead -- as these allow for a faster ability to skim through and see if it is what you need.

Now that we have some code to mess with, lets get to prototyping.