Nifflas' Support Forum

Being Creative => Creativity Support => Topic started by: Joho The Hobo on April 24, 2009, 23:55:14

Title: GIF to the beat
Post by: Joho The Hobo on April 24, 2009, 23:55:14
Hey, all you most knowledgeable forum-goers, I have a Question.

Does anybody have any idea how I could go about making an animated GIF move to the (automatically detected) beat of a song?

I have an idea of how to detect the song's beat, by detecting any regular peaks in the bass notes, but this is only conceptually, I haven't a clue how to put it into code. Nor, in all honesty, do I have any experience in working with GIFs, so I'm going to need help pretty much from square one in this.  :/

If anyone knows of any ready-made solutions for this, or parts of it, that'd be great. The only language I've had any real experience in is Python, though I'd be willing to give any others people think would work a try.
Title: Re: GIF to the beat
Post by: StaticRomantic on April 25, 2009, 00:01:27
You could try finding the BPM (beats-per-minute) of the song, then syncing it up with the FPS of the gif.

But I'm inexperienced with gifs and thats just me thinking out loud  :oops:

To open up a song file, try using an audio program like Audacity (http://audacity.sourceforge.net/). Most music programs have features that automatically find the BPM. I think Audacity does as well. If nothing else, at least you would have the visual sound file in front of you. I'm sure theres other things you could do in that program that would help.
Title: Re: GIF to the beat
Post by: Joho The Hobo on April 25, 2009, 00:08:49
Thanks :) , I have Audacity, though it never actually occurred to me to use it to find BPM.  :oops:

I'd like to be able to import GIFs to the program though, not just make them one at a time. This way I could sinc any GIF to any song, like a sort of visualizer.
Title: Re: GIF to the beat
Post by: googoogjoob on April 25, 2009, 00:50:02
...I really doubt it's possible to have a GIF which auto-syncs with any piece of music. The framerate dealy of the GIF would have to be altered constantly in accordance with the beat, while the GIF was being displayed. Syncing a GIF with a particular track, though, would be reasonably easy.

In my experience, Audacity's beat finder is horrifically inaccurate, unless the rhythm is especially prominent and stays the same level throughout the track. Also, it doesn't give output in BPM; it makes a label track with flags on each (perceived) beat.
Title: Re: GIF to the beat
Post by: Joho The Hobo on April 25, 2009, 02:24:22
Hmm... I see. Well I suppose I could break the GIF into separate images for each frame, then animate that to the music, for the same visual effect?

Thanks for the advice. In case you haven't noticed, I'm pretty much out of my depth here :P2 , but it should be a good learning experience.

As I see it, to make this work I need to:

This involves images, audio, animation... Is there any programming languages/tools that can handle all this without too much fuss? Or failing that, handle them with fuss?
Title: Re: GIF to the beat
Post by: StaticRomantic on April 25, 2009, 09:13:53
you could get a rough estimate of BPM by using a metronome and syncing it up.
I'm just brainstorming  O_o
best bet is.... google (http://www.google.com/search?q=find+bpm+of+a+song&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a) (try the first link on there. looks promising.)
Title: Re: GIF to the beat
Post by: LPChip on April 25, 2009, 10:45:05
Using Gif is something that is not really possible. You cannot "sync" a gif with anything else, but you can try to program the gif so it looks synched. If however either the gif or the music holds for a second, it no longer will be in sync.

You could however, probably do this with flash.
Title: Re: GIF to the beat
Post by: Joho The Hobo on April 26, 2009, 18:11:54
Okay, thanks to all.
Hmm, well i guess GIFs wont work, but I'll not give up on the idea, it couldn't be too hard to work around the file format, converting the GIF into jpeg stills or something. I'll look around myself some more, see if I can find anything useful.

I was inspired by this, by the way: http://emmy.eviltrailmix.com/dancedancesmall.gif (http://emmy.eviltrailmix.com/dancedancesmall.gif)   :)

I've had it open in the corner of my screen whenever I'm listening to music recently, but I'd rather have a little window which I could drag it (or any other non-synched GIF) into, to display is as a beat-following animation.
Title: Re: GIF to the beat
Post by: Joho The Hobo on April 28, 2009, 01:24:11
I've got a thing running which breaks a GIF into separate png files for each frame now, which is a step in the right direction, :D but I've run immediately into more problems.  :moody:

Does anybody now know any way of getting a Python module written for Python version 2.4 to work in Python 2.5? Is this even possible?
Title: Re: GIF to the beat
Post by: LPChip on April 28, 2009, 22:19:40
If you can program your best option would be to program a visualisation to use in say... XMPlay or another famous player. Then you have all the tools for beat detection and it works on any song without modifying anything. Though that will still be very difficult.

I have no knowledge about Python so I cannot answer that question for you.
Title: Re: GIF to the beat
Post by: utherdoul on May 21, 2009, 15:26:37
Sorry if this is a bit necromantic, but I just happened upon this thread. What you could do is use a film-editing such as Adobe Premiere (in my opinion the bet and most accessible, though not cheap!) and you can then import images (including animated gifs - but not on a Mac) and add your music on the audio timeline.

Actually, if you've already got a program to split the animated gif into images, it'd make the whole process much easier.

Then it'd be a case of syncing it manually (which is as simple as dragging the images to the required lengths) and then export again to animated gif. You'd have to keep an eye on the export properties to make sure it doesn't mess with your framerate.

I'm not really familiar with other film-editing programs, but I know you can do exactly the same with Windows Movie Maker other than export as anything useful (I hate Windows Movie Maker) - but I'm sure there are free video editing things out there if you can't shell out for Premiere. Then again I'm not sure what the limitations are, but you could also try using the Premiere trial version...
Title: Re: GIF to the beat
Post by: Evil on June 05, 2009, 02:47:21
^You can get the data from the sound and convert it to keyframes  :)