Amish Brothers Time-lapse with Guide

This is a time-lapse video of my development of Amish Brothers for Ludum Dare 26. The video footage was taken from my Twitch.tv stream.

Generating a time-lapse video from a Twitch.tv stream is not a trivial task. I will describe the process that I used to create this video. This is only a suggested method, and I do not suggest, promote, or advocate any of the software packages described below. Use all software at your own risk.

First, you will need all of your Twitch.Tv video clips. These can be downloaded from http://bashtech.net/twitch/download.php . You will need to connect your twitch.tv account with your username and password. I believe the authentication is through Twitch.tv, so it should be safe, but don’t hold me to that. To be on the safe side, make sure your Twitch.Tv password is unique from any other passwords that you use.

Then start pressing the Next button until you get to the videos that you want to use for your time lapse. If you’re like me, you named these videos something like Ludum Dare. Now for the monotonous part, start downloading each of the video streams into a folder of your choosing. These videos will be saved in FLV format. Unfortunately, this site provides your videos in 30 minute chunks, so there may be numerous video files to download. 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.

Download and install the VLC video player from http://www.videolan.org/vlc/ .

VLC can be used to generate snapshots of an FLV video as specified frame intervals using a command like the one below from a Windows command prompt.

> vlc C:ludumdaremyvideo.flv --rate=1 --video-filter=scene --vout=dummy --start-time=1 
--stop-time=1800 --scene-format=png --scene-ratio=24 --scene-prefix=snap 
--scene-path=C:ludumdarescreens vlc://quit

This tells VLC to generate a snapshot every 24 frames for the first 1800 seconds (30 minutes). This works okay, but the stream has to completely play through the entire 30 minutes to take the snapshots. Therefore, it will take the total amount of casting time to grab all of the snapshots for the time-lapse video. This method could take hours for to grab all the snapshots out of the stream videos.

Note: The path to VLC must be in your PATH environment variable. This can be done in a command prompt using a command such as the one below. Change the value accordingly for your VLC installation.

set PATH=%PATH%;C:Program Files (x86)VideoLANVLC

To make this process more efficient, we only want to play the video at the points where we will capture a snapshot. This can be accomplished by changing the start-time and stop-time values. When specifying those values, VLC will start generating snapshots at that number of seconds into the clip. However, there is an apparent bug which makes VLC also generate a snapshot at the beginning of the video as well.

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. Repeat this process by incrementing the start-time parameter by the interval between frames in seconds. I set the stop-time to the start-time + 1, since we only want to capture one frame at that time. 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. In most cases, that value will probably be 24 frames per second for Twitch.tv.

I chose to take one frame every 30 seconds for my Amish Brothers time lapse video. I scripted this process in Ruby, so that it automatically calls VLC with the correct time parameters. 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.

That is good, but I had 37 videos to process, which is still tedious. With a little more scripting, I was able to loop through all of the FLV files that I had downloaded into my video directory. After the script is complete, it puts all of the PNG image files in the “screens” directory. 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 “*00001.png” files, leaving only the correct snapshots remaining in the directory.

Below is the Ruby code for generating the snapshots with VLC.

USE AT YOUR OWN RISK AND ONLY IF YOU KNOW WHAT YOU ARE DOING!

iFramesPerSecond = 25
iSecondInterval = 30
iFrameCounter = 1
Dir.foreach('.') do | strFile |
  if (strFile =~ /.flv/)
    iStartTime = 1
    while (iStartTime < 30 * 60)
      strFrame = "%05d" % iFrameCounter
      strCommand = "vlc #{strFile} --rate=1 --video-filter=scene --start-time=#{iStartTime} 
--stop-time=#{iStartTime + 1} --vout=dummy --aout=dummy --scene-format=png 
--scene-ratio=#{iFramesPerSecond - 1} --scene-prefix=#{strFrame}f 
--scene-path=.\screens vlc://quit"
      puts "Running #{strCommand}"
      system(strCommand)
      iFrameCounter += 1
      iStartTime += iSecondInterval
    end
   end
 end

Next, I went through my snapshot directory and removed unneeded images, such as when I was eating or away on a bathroom break.

Now I needed to put the snapshots back together in a video file. 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. Therefore, I used VirtualDub (http://virtualdub.org/), which can also make a video out of image files.

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. To resolve this, I wrote another Ruby script which looped through all my snapshot images and renamed them to sequential file names. I’m not sure if the files are looped through by lexicographical order or timestamp order by default, but it worked so I’m not complaining.

USE AT YOUR OWN RISK AND ONLY IF YOU KNOW WHAT YOU ARE DOING!

iFile = 1
Dir.foreach('.') do | strFile |
  if (strFile =~ /.png/)
    strNewName =  "%05d" % iFile
    strNewName += ".png"
    puts "Old: #{strFile} New: #{strNewName}"
    File.rename(strFile, strNewName)
    iFile += 1
  end
end

Now all of my images are in the directory in sequential order by file name. The images can be imported into VirtualDub by selecting File > Open Video File and selecting the first image. It will automatically add all of the other images in the directory. I also added an audio track using some of the music from my game, by selecting Audio > Audio from other file. 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.

Finally, I added a credits screen at the end, which seemed to be more trouble than it was worth. 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 > Append AVI segment to add it to the end.

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. This was fixed by selecting Video > Compression from the VirtualDub menu. It gives a few different compression methods. I didn’t really have a clue as to which one is best, so I just selected Microsoft Video 1. It reduced the size to around 400 Megs, so it did the job.

Finally, I previewed the video and uploaded to YouTube. It seemed to a be a lot of trouble just to make a time-lapse video, but this was my method since I didn’t not use a screen capture program and I didn’t want to spend a lot of money on a professional video package.

 

References:

http://wiki.videolan.org/How_to_create_thumbnails

http://code.google.com/p/chronolapse/

http://support.twitch.tv/discussion/2391/frequently-asked-questions

http://www.ludumdare.com/compo/2012/09/09/how-to-make-a-good-timelapse/

https://wiki.videolan.org/VLC_command-line_help

Amish Brothers

Amish Brothers
Play online


Amish Brothers

Amish Brothers Overview

Who are more minimalist than the Amish? Welcome to Amish Brothers where you play as Brother Jedidiah, who must return all of the farmyard animals to the barn. Ten levels of sheep catching action!  Amish Brothers was my submission for the “Minimalist” theme for a game jam.

Post Mortem

So when I heard that the theme for this year’s game jam was Minimalism, I immediately thought of an episode of the radio show Coast to Coast AM with Art Bell, where the episode was on minimalist societies. There are many who follow the minimalist lifestyle today, by using only the bare necessities to get by in life. However, the original practitioners of the minimalist lifestyle are the Amish. I started thinking and realized there has never been a video game about the Amish before, at least as far as I’m aware. Then I remembered the 90’s classic song Amish Paradise by Weird Al Yankovic. This could actually be an interesting premise for a game.

An Amish that would save the world using only the bare necessities. The next question is how would he save the world. Obviously an Amish would not want to hurt or kill anyone, so I decided narrow the grandiose premise of the game. Instead of the protagonist attacking others, he would be helpful.

Original title screen for  compo entry

For the game jam, I knew that web is the platform that could reach the most players, so Unity was the best environment to develop a game for this competition. Not knowing anything about Unity, I started watching as many tutorial videos I could the night before the competition to give me a basic feel for using the tool. Even though I’m not a Unity guru, I’ve been programming games in my spare time since around 1995. My first epic game was Mystic Sword written in QBasic on my 386. Since then I have written games using libraries such as ClanLib, SDL, and most recently XNA for XBox Live Indie Games. Last year I released my first published game called Resistor to the masses on the XBox Live Indie Game platform. While it was praised by many XBox Indie review sites, I failed to make any monetary return since it didn’t sell enough copies to get the minimum payout. I decided to start working on a new game called Blasting Bits, which would appeal to more gamers. I worked on this platformer in my spare time for about six months, then an unexpected event occurred in my life, which made me lose my enthusiasm of developing games. However, I knew I still wanted to do the game jam competition this time, since I’ve never done it before and it seemed like it would be fun.

So after my crash course in Unity, I knew enough to move an object around and how to detect an event when that object collided with another object. Hey, that sounds like enough to make a game! Not enough to make a deep and sophisticated game, but enough to make a simple collectible game. Then I decided that the hero, who I named Brother Jedidiah, would collect sheep… because sheep are cute. After sleeping on it for a night, I thought of a simple story about the farmyard animals escaping the barn. I had planned to include other animals such as chickens, cows, and goats, which would have unique characteristics and travel patterns, but I didn’t have enough time to implement those so I stuck with sheep. I also considered adding powerups such as a butter churn to make the player run faster, but that idea got left on the cutting room floor for the sake of completing the game on time.

Original compo entry gameplay

I added some simple boxes to the screen that represented the player and the sheep. Then I developed a method for automatically generating the sheep, using the Prefab technique that I learned in the Unity tutorial. Next I started working on the model assets. I’ve been modeling simple objects in Blender for over ten years, so I knew I could make a player model and sheep model for this competition. The only problem was adding the models into Unity was something I had never done before. I’ve gotten animated models working in XNA before by exporting to FBX, but I never had the ability to change animation sequences. I was delighted to discover that importing models into Unity is as simple as dragging the .blend file into the Unity project. Unfortunately, my models were not animating in Unity, which had me pulling out my hair for awhile. After some searching on the Internet, I found that the Animation Type must be set to “Legacy” on the Rig tab for animations to work. Then I created a simple barn, trees, and fence to add to the scenery. Finally, I rendered a stack of potatoes as a small Easter egg, which can be seen on the left side of the farm.

For the audio, I recorded myself reading the introduction story using Audacity. I also made a “baa” sound, which I sped up and raised the pitch in Audacity to make it sound more like a sheep. Finally, I needed some music so I recorded myself playing “Old MacDonald” and “Baa Baa Black Sheep” on the guitar. I thought those songs fit the atmosphere of my game perfectly.

The level design was really simplistic, as I just increased the number of sheep for each level. Some have expressed dissatisfaction due to the lack of a lose state. However, not all games have lose states. In a racing game, you can just sit in your car forever and never reach the finish line. I feel my game is a lot like bubble wrap. You just keep popping bubbles until they’re all gone. Adding enemies such as snakes and obstacles like briars did cross my mind, but I envisioned this being a game for the entire family, so I wanted to avoid having the main character get killed. I also wanted to make mazes out of the fence, but I knew I wouldn’t be able to compete that within 48 hours. Finally, I made a victory screen and congratulations message for when the player completes all ten levels.

So that’s Amish Brothers in a nutshell. I would like to expand the game a little more to make it more interesting, but I also have a few ideas for other games I would like to start making with Unity as well.

Videos

 

 

Released

Amish Brothers Complete

Who are more minimalist than the Amish? Welcome to Amish Brothers where you play as Brother Jebidiah, who must return all of the farmyard animals to the barn. Ten levels of sheep catching action!

amishbrothers03

This is my first game created in Unity. The development environment has a little bit of a learning curve, but once I got the hang of it most of it made sense. I really like Unity’s ability to import Blender (.blend) models directly into the project. This is something that I have been fighting with in XNA for over six months. The biggest trick was figuring out that I had to select the “Legacy” option under the model’s “Rig” settings. Getting the models to rotate the correct way was also a bit of a challenge, since rotating at the incorrect place will cause the movement vector to change as well.

It was a really enjoyable experience creating all of the assets for the game. All of the models were created in Blender. The music was me playing the guitar with touch-up done in Audacity. The sheep sound was also me, with some pitch and speed distortion in Audacity.

I’m really anxious to hear what people think of the game. I’ll admit that it isn’t the most complex game, but I think it appropriately fits the “minimalism” theme of this Ludum Dare competition.

amishbrothers01

Play the game here: Amish Brothers

Contact me @GaTechGrad on Twitter