发布视频

    “House of Cards”视频是在G公司网站上首映的第一个音乐视频,它在2008年7月11日发布。G公司站点包含了一些该视频的数据,因此你可以创建自己的可视化以及3D数据可视化工具。G公司的创新实验室开发了这个站点。

    该可视化工具是由我和朋友Aaron Meyers一起用Flash开发的。它允许观看者在播放视频期间实时旋转云点数据。对我来说,这正是数据美丽之处。Flash应用允许你实时从任意视角查看视频,这是传统的视频记录所不能及的。你可能旋转Thom Yorke的脸庞,这样他从远处望着你,有效地把持住他的脸作为你的面具,你就可以透过他的眼睛。在我看来,这种效果非常强大。它使得音乐视频在某种方式上变得有形,我怀疑很多人都没有过这种体验。

    我们还发布了一些数据(把数据开源)以及通过Processing编程语言开发的视频创建工具。然后,我们鼓励人们下载数据来创建他们自己的视频。

    我想为视频创建工具分享源代码,以便展示通过Processing创建你自己的视频时多么简单。以下是输出Thom Yorke歌唱的帧的代码:


    import processing.opengl.*; int frameCounter=1; //Declare a variable to store which frame we're dealing with void setup(){ //Here we set up the program size(1024,768,OPENGL); //This is the render size.We'll use OpenGL to draw as //fast as possible //frameRate(30); //Uncomment to watch the animation at 30 frames per second. strokeWeight(1); //Draw lines at a width of 1,for now.

    }

    void draw(){ //Here we state the things we're going to do every frame background(0); //We'll use a black background translate(width/2,height/2); //The data has 0,0,0 at the center and we want to //draw that point at the center of our screen translate(-150,-150); //Let's adjust our center slightly scale(2);//Let's draw things bigger //rotateY(frameCounter/50.0f); //If uncommented,this makes the data rotate over //time //rotateY(mouseX/150.0); //If uncommented,this uses the mouse's horizontal //location to adjust the rotation String[]raw=loadStrings(frameCounter+".csv");//Here we load the current frame //data into an array for(int i=0;i<raw.length;i++){ //Now we loop through each line of the //raw data String[]thisLine=split(raw[i],','); //For each line we're going separate //each parameter float x=float(thisLine[0]); //Now we make a decimal variable for each //parameter float y=float(thisLine[1]); float z=float(thisLine[2]); int intensity=int(thisLine[3]); stroke(intensity1.1,intensity1.6,200,255);//We set the color of each point to //correspond to the data's //intensity value line(x,y,z,x+1,y+1,z+1); //Here we draw a little line for each point;this //is much faster than a more complex object and//we'll be drawing a lot of them } frameCounter++;//Add one to the frame variable to keep track of what frame we're //currently on if(frameCounter>2101){ //If we get to the end of the data we'll exit the //program exit(); println("done");

    }

    //saveFrame("renderedFrames/"+frameCounter+".tga"); //This would be a way to save out //a frame //remember you're saving files to your harddrive!

    }


    它没有数据那么美(毕竟本书不是《代码之美》),但是它的效果很好。正如代码所示,它允许你从头到尾观看Thom Yorke的歌唱,但是有一些修改,你可以定制这个过程。以下是两个修改实例,基于之前的代码做出注释。第一个修改实例是:


    rotateY(frameCounter/50.0f);

    把绘图函数的起始部分的这行代码取消注释,将会导致Thom的脸随着帧的增加而向y轴旋转。

    第二个修改实例是:


    rotateY(mouseX/150.0);

    把绘图函数起始部分的这行代码取消注释,允许你对鼠标函数进行旋转。你现在可以随着帧的输出移动Thom的脸。

    我相信你能够想到一些其他方面来修改。很多人做了我从来没有想到的事情,这正是我期望的。对所有的帧进行渲染(把最后一行取消注释)并放在一起生成一个视频,就可以制作类似QuickTime Pro、Final Cut或After Effects这样的节目了。其他人创建的一些视频令人印象深刻。在Youtube的“House of Cards”组(htp://www.youtube.com/group/houseofcards)上看到这些视频。

    这一切真的都非常简单;只需要在开始实践时有一些美丽的数据。