{"assets":[],"author_link":"author\/gatechgrad\/","author_name":"Levi D. Smith","cat":"LD #26","categories":["LD #26"],"comments":[],"epoch":1367343120,"event":"LD26","likes":2,"metadata":{"p_key":"79214","p_author":"Levi D. Smith","p_authorkey":"0","p_urlkey":"288224","p_title":"Amish Brothers Time-lapse with Guide","p_cat":"LD #26","p_event":"LD26","p_time":"1367343120","p_likes":"2","p_comments":"0","p_status":"WAYBACK","us_key":null,"us_name":null,"us_username":null,"event_start":"1366934400","event_key":"16","event_name":"LD26"},"source_url":"2013\/04\/30\/amish-brothers-time-lapse-with-guide\/","text":"<p>This is a time-lapse video of my development of Amish Brothers for Ludum Dare 26.\u00a0 The video footage was taken from my Twitch.tv stream.<\/p>\n<p><iframe allowfullscreen=\"\" frameborder=\"0\" height=\"281\" src=\"http:\/\/www.youtube.com\/embed\/Ax4p5wOBxNk?feature=oembed\" width=\"500\"><\/iframe><\/p>\n<p>Generating a time-lapse video from a Twitch.tv stream is not a trivial task.\u00a0 I will describe the process that I used to create this video.\u00a0 This is only a suggested method, and I do not suggest, promote, or advocate any of the software packages described below.\u00a0 Use all software at your own risk.<\/p>\n<p>First, you will need all of your Twitch.Tv video clips.\u00a0 These can be downloaded from http:\/\/bashtech.net\/twitch\/download.php .\u00a0 You will need to connect your twitch.tv account with your username and password.\u00a0 I believe the authentication is through Twitch.tv, so it should be safe, but don\u2019t hold me to that.\u00a0 To be on the safe side, make sure your Twitch.Tv password is unique from any other passwords that you use.<\/p>\n<p>Then start pressing the <em>Next<\/em> button until you get to the videos that you want to use for your time lapse.\u00a0 If you\u2019re like me, you named these videos something like <em>Ludum Dare<\/em>.\u00a0 Now for the monotonous part, start downloading each of the video streams into a folder of your choosing.\u00a0 These videos will be saved in FLV format.\u00a0 Unfortunately, this site provides your videos in 30 minute chunks, so there may be numerous video files to download.\u00a0 If you are clever, you can probably script a process to speed up the download process using a web file grabber like wget or curl.<\/p>\n<p>Download and install the VLC video player from http:\/\/www.videolan.org\/vlc\/ .<\/p>\n<p>VLC can be used to generate snapshots of an FLV video as specified frame intervals using\u00a0 a command like the one below from a Windows command prompt.<\/p>\n<pre>&gt; vlc C:\\ludumdare\\myvideo.flv --rate=1 --video-filter=scene --vout=dummy --start-time=1 \r\n--stop-time=1800 --scene-format=png --scene-ratio=24 --scene-prefix=snap \r\n--scene-path=C:\\ludumdare\\screens vlc:\/\/quit<\/pre>\n<p>This tells VLC to generate a snapshot every 24 frames for the first 1800 seconds (30 minutes).\u00a0 This works okay, but the stream has to completely play through the entire 30 minutes to take the snapshots.\u00a0 Therefore, it will take the total amount of casting time to grab all of the snapshots for the time-lapse video.\u00a0 This method could take hours for to grab all the snapshots out of the stream videos.<\/p>\n<p><em>Note: The path to VLC must be in your PATH environment variable.\u00a0 This can be done in a command prompt using a command such as the one below.\u00a0 Change the value accordingly for your VLC installation.<\/em><\/p>\n<pre>set PATH=%PATH%;C:\\Program Files (x86)\\VideoLAN\\VLC<\/pre>\n<p>To make this process more efficient, we only want to play the video at the points where we will capture a snapshot.\u00a0 This can be accomplished by changing the start-time and stop-time values.\u00a0 When specifying those values, VLC will start generating snapshots at that number of seconds into the clip.\u00a0 However, there is an apparent bug which makes VLC also generate a snapshot at the beginning of the video as well.<\/p>\n<p>Now to generate all of the snapshots, we will need to execute VLC setting the start-time parameter to the value of the position where the snapshot should be taken.\u00a0 Repeat this process by incrementing the start-time parameter by the interval between frames in seconds.\u00a0 I set the stop-time to the start-time + 1, since we only want to capture one frame at that time.\u00a0 Be careful to make scene-ratio the value of the frames per second for the cast, so that only one snapshot is taken for the one second interval.\u00a0 In most cases, that value will probably be 24 frames per second for Twitch.tv.<\/p>\n<p>I chose to take one frame every 30 seconds for my Amish Brothers time lapse video.\u00a0 I scripted this process in Ruby, so that it automatically calls VLC with the correct time parameters.\u00a0 This made the total time to generate the snapshots for a 30 minute video 60 seconds (2 snapshots generated for each minute of footage at one second each), but maybe a little longer due to some overhead of starting and stopping VLC.<\/p>\n<p>That is good, but I had 37 videos to process, which is still tedious.\u00a0 With a little more scripting, I was able to loop through all of the FLV files that I had downloaded into my video directory.\u00a0 After the script is complete, it puts all of the PNG image files in the \u201cscreens\u201d directory.\u00a0 However, there is that bug in VLC that generates an image at the start of the video, so with a simple DOS delete command I removed all of the \u201c*00001.png\u201d files, leaving only the correct snapshots remaining in the directory.<\/p>\n<p>Below is the Ruby code for generating the snapshots with VLC.<\/p>\n<p>USE AT YOUR OWN RISK AND ONLY IF YOU KNOW WHAT YOU ARE DOING!<\/p>\n<pre>iFramesPerSecond = 25\r\niSecondInterval = 30\r\niFrameCounter = 1<\/pre>\n<pre>Dir.foreach('.') do | strFile |\r\n  if (strFile =~ \/\\.flv\/)<\/pre>\n<pre>    iStartTime = 1\r\n    while (iStartTime &lt; 30 * 60)<\/pre>\n<pre>      strFrame = \"%05d\" % iFrameCounter<\/pre>\n<pre>      strCommand = \"vlc #{strFile} --rate=1 --video-filter=scene --start-time=#{iStartTime} \r\n--stop-time=#{iStartTime + 1} --vout=dummy --aout=dummy --scene-format=png \r\n--scene-ratio=#{iFramesPerSecond - 1} --scene-prefix=#{strFrame}f \r\n--scene-path=.\\\\screens vlc:\/\/quit\"\r\n      puts \"Running #{strCommand}\"\r\n      system(strCommand)<\/pre>\n<pre>      iFrameCounter += 1\r\n      iStartTime += iSecondInterval<\/pre>\n<pre>    end\r\n   end\r\n end<\/pre>\n<p>Next, I went through my snapshot directory and removed unneeded images, such as when I was eating or away on a bathroom break.<\/p>\n<p>Now I needed to put the snapshots back together in a video file.\u00a0 Some people have recommended Chronolapse, but I tried it and the video quality was really poor and there were no options to increase the quality.\u00a0 Therefore, I used VirtualDub (http:\/\/virtualdub.org\/), which can also make a video out of image files.<\/p>\n<p>The only problem with VirtualDub is that it expects the filenames to be in sequential order (0001.png, 0002.png, 0003.png, etc), and the filenames generated by VLC can only be specified by a prefix, and it gives each file an unchangeable ending, which is based on the frame number.\u00a0 To resolve this, I wrote another Ruby script which looped through all my snapshot images and renamed them to sequential file names.\u00a0 I\u2019m not sure if the files are looped through by lexicographical order or timestamp order by default, but it worked so I\u2019m not complaining.<\/p>\n<p>USE AT YOUR OWN RISK AND ONLY IF YOU KNOW WHAT YOU ARE DOING!<\/p>\n<pre>iFile = 1<\/pre>\n<pre>Dir.foreach('.') do | strFile |<\/pre>\n<pre>  if (strFile =~ \/\\.png\/)<\/pre>\n<pre>    strNewName =\u00a0 \"%05d\" % iFile\r\n    strNewName += \".png\"<\/pre>\n<pre>    puts \"Old: #{strFile} New: #{strNewName}\"\r\n    File.rename(strFile, strNewName)<\/pre>\n<pre>    iFile += 1<\/pre>\n<pre>  end<\/pre>\n<pre>end<\/pre>\n<p>Now all of my images are in the directory in sequential order by file name.\u00a0 The images can be imported into VirtualDub by selecting File &gt; Open Video File and selecting the first image.\u00a0 It will automatically add all of the other images in the directory.\u00a0 I also added an audio track using some of the music from my game, by selecting Audio &gt; Audio from other file.\u00a0 It is important to note that VirtualDub will not loop your audio, so I had to manually loop the audio myself by extending the audio track in Audacity.<\/p>\n<p>Finally, I added a credits screen at the end, which seemed to be more trouble than it was worth.\u00a0 There is no way to slow down or copy frames in Virtual Dub, so I had to make another video file containing my credits, and then used File &gt; Append AVI segment to add it to the end.<\/p>\n<p>Now I just needed to encode the video, but it turned out to be about 5 Gigs in size, which I believe is too big for YouTube.\u00a0 This was fixed by selecting Video &gt; Compression from the VirtualDub menu.\u00a0 It gives a few different compression methods.\u00a0 I didn\u2019t really have a clue as to which one is best, so I just selected Microsoft Video 1.\u00a0 It reduced the size to around 400 Megs, so it did the job.<\/p>\n<p>Finally, I previewed the video and uploaded to YouTube.\u00a0 It seemed to a be a lot of trouble just to make a time-lapse video, but this was my method since I didn\u2019t not use a screen capture program and I didn\u2019t want to spend a lot of money on a professional video package.<\/p>\n<p>\u00a0<\/p>\n<p>References:<\/p>\n<p>http:\/\/wiki.videolan.org\/How_to_create_thumbnails<\/p>\n<p>http:\/\/code.google.com\/p\/chronolapse\/<\/p>\n<p>http:\/\/support.twitch.tv\/discussion\/2391\/frequently-asked-questions<\/p>\n<p>http:\/\/www.ludumdare.com\/compo\/2012\/09\/09\/how-to-make-a-good-timelapse\/<\/p>\n<p>https:\/\/wiki.videolan.org\/VLC_command-line_help<\/p>\n<p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/timelapse\/\" rel=\"tag\">timelapse<\/a><\/p>","time":"April 30th, 2013 5:32 pm","title":"Amish Brothers Time-lapse with Guide","title_was_empty":false}