This is really awesome. They cut the entire song into one-beat segments of sound and video, and then categorized each beat by similarity to other beats in the song, and then after each beat there's a random chance that, instead of playing the next beat, the playback will transition to a different but similar-sounding beat from elsewhere in the song.
More info at the author's blogpost: http://musicmachinery.com/2012/10/28/infinite-gangnam-style/