Category Archives: Play

Video editing with PiTiVi

For my last video project I used Blender. It is a very capable video editor but it has a steep learning curve and is complex. I wanted something easier that I could show the kids how to use. They have had some exposure to iMovie at school. Ubuntu 10.04 (Lucid) comes with a few more video editing options than past releases. I decided to give PiTiVi a try.

Over all PiTiVi is fairly good for such a young product. It has lots of potential to be both powerful and easy to use. The documentation is good, straight forward, and easy to understand. It does leave out some background or supplemental information which I had to figure out on my own. This is not a tutorial, just some information that may be useful to others trying it out.

The video project I choose is a marble timer built with K’NEX that my daughter Isabella and I made for a school project of hers last year. The video was shot with a Flip HD camera.

I installed the latest PiTiVi version. There really is good reason to use a newer version than the one that comes with the Lucid software sources. There are many improvements and new features. The PiTiVi download page gives instructions on how install from the Ubuntu PPA (Personal Package Archive). I used version 0.14.0-2.

The Flip takes nice video but the HD resolution (1280×720) can make it difficult to work with on underpowered computers. I have an old Z61m ThinkPad with a 64MB ATI Mobility Radeon x1300 video card. It has no problem playing back HD video but it could not handle editing.

The PiTiVi documentation talks about friendly video formats. It says frame-independent compression formats such as MJPEG will perform better. I figured editing may work better if I convert my Flip video, which uses a H.264 / AVC codec to MJPEG or even uncompressed. I tried both. The uncompressed AVI files were huge and didn’t perform any better so I stuck with MJPEG. It took me a while to figure out how to convert the files. Since PiTiVi is based on GStreamer I decided to try using it. There may be other tools for this. I had to learn a lot about Gstreamer and its command line program gst-launch. The command line I finally figured out is this (just change the src and sink file names):

gst-launch filesrc location=VID00001.MP4 ! decodebin name=demux demux. ! queue ! ffmpegcolorspace ! jpegenc ! mux. demux. ! queue ! mux. avimux name=mux ! filesink location=vid0001.avi

The performance was better with these files. If there was only one clip I could scrub and play back with no problem but as soon as I added another clip the video was choppy. I could have tried reducing the resolution of the video but I really wanted the result to be in HD otherwise what is the point of taking video in HD in the first place. I decided since my video would be fairly simple and short that I could manage to edit it with choppy video. I could advance a frame at a time to check fades and transitions. Audio playback was in real time.

The titles were made with GIMP. When added as a clip they are automatically turned into video.

The most complicated thing about my video is the timer overlay. To do this I created a solid green frame using GIMP brought it into a new PiTiVi project added it as a clip and made it 30.5 seconds long. Then I rendered this to MJPEG. This gave me a green screen video 30 and a half seconds long. Then I used the pango timeoverlay plugin in the following command to add the timer.

gst-launch filesrc location=green.avi ! decodebin ! timeoverlay halign=right valign=bottom xpad=100 ypad=50 font-desc="serif bold 20px" ! ffmpegcolorspace ! jpegenc ! avimux ! filesink location=timer.avi

I added the resulting timer.avi file as a clip above the marble track video and used the alpha filter effect so that the green was transparent. This gives a counting timer overlaid on the marble video. All that remained was to start it when the marbles started and trim it when the last marble hit the table.

PiTiVI has plenty of effects. The one I wanted to use was Bulge. I would have used it on the main title screen but I wanted it to move across the screen. The effects will be much better once they can be animated over time with the key frames. Also if the pango plugin was available in the effect library perhaps I wouldn’t have needed to use a command line.

One problem the video has that I couldn’t find a way to fix is an audio glitch at the beginning and end of each voice over. The voice over quality in general is not that good probably due to a cheap microphone. The voice was recorded separate from the video. I used Audacity to cleanup the audio some.

I tried rendering in a few different formats. 1) MP4, FFmpeg PEG-4 part 2, ACC. This produced a very small file (16MB) and rendered quickly but the video quality was very poor. 2) Ogg, Theora, Vorbis. This produced very good quality video. Render time was about 20min. The file size is 187MB. 3) AVI, FFmpeg motion jpeg, ACC. The video quality was not very good the file was large (127MB) but the render time was very fast (~7min). 4) WebM, On2 VP8, Vorbis. The video quality was very good, the file was small (22MB) but it took about 44 min to render. Uploading the WebM format to youtube didn’t work so I uploaded the Ogg format. There are many other rendering options but these are the only ones I have tried so far. The audio glitch was present in all rendering formats.

My wish list for PiViTi:

The documentation should include more information on preferred video formats for editing and how to use external tools to do the conversion. Even better would be built-in tools do do the conversion.

The documentation should give advice on different rendering combinations. There are many containers each with different options for video and audio codecs. It would be nice to have a simplified dialog that chooses a recommended output format based on high level choices such as what do you plan to do with the video (burn to DVD, upload to YouTube etc.) and other choices like do you prefer open standards.

The render dialog should remember the last folder I rendered into.

Here is a direct link to the video.

Lego Climbing Robot

Way back in January I watched a Google tech talk video Lego Engineering: from kindergarten to college. The talk stresses the importance of teaching engineering in schools. A few days later at breakfast I started talking with my oldest daughter, Alexandria, about engineering and what it is that engineers do. I said that engineers use what they know about science and how things work to find solutions to challenges. I threw out a challenge as an example: Build the tallest possible tower that fits in our house and then build a robot to climb it. It was just an example but she got really excited about the idea. “Can we build it. Can we. Can we.” she said. I said “sure”.

In March I posted a preview of the robot with a picture and promises of more details to come. Its taken me way to long to finally write it up. The robot has been done since May and has made a dozen or so ascents. Making the video is what caused the delay.

Here is what I remember of the process.
Continue reading Lego Climbing Robot


I don’t expect my kids to become programmers like their dad. I wouldn’t wish it for them unless it is what they want for themselves. Still, I think there is value in getting exposure to programming for a number of reasons – thinking logically, planning, designing, applying math, understanding how things work and fostering creativity to name a few.

The question is when and how to introduce kids to programming. Scratch may be the answer to how and right about now the answer to when. Scratch is a new language from the Lifelong Kindergarten group at the MIT Media Lab designed to make it fun and easy for kids 8 and up to create programs. My kids and I found Scratch instantly compelling. Everything about Scratch, from the friendly looking cartoon cat that starts out in each new project, to the building block style programming, to the sharing of projects on the Scratch web site has been designed for and appeals to the youngest possible audience.

My kids are at the young end of the target age range for Scratch so I don’t expect too much programming from them at this point. The important thing is that they are really excited to use the program. They create projects to collect, edit and arrange pictures. They are interested in seeing and trying the projects that other people have created. It provides a context for me to talk to them about things like the X, Y coordinate system in terms of the number line they already know and what it is used for in moving things around on the screen.

Just the other night I was sitting with my youngest and she had chosen a cartoon girl sprite and a bedroom background. Then she asked “can we make her jump up and down on the bed”. I said “sure” and in a few minutes I showed her how. A block to move up. Click, a block to move down. Put them in a repeat loop, click. How many times do you want her to Jump? Twenty, OK. Oops, too fast. Click, add a wait block. Done. Then I introduced her to variables so she could control how many times the girl jumped.

The Scratch web site provides a social network where people (I say people because it is not just kids playing with Scratch) can share their projects and ideas. Any uploaded project can be downloaded by anyone so they can open it up and learn how it works or simply just play with it. This really fosters learning and building on the ideas of others. You will see some comments complain of copying or ripping off ideas but overall the site promotes an attitude of sharing. Knowledge and ideas are not a scarce resource to be horded and protected they are abundant and should be shared. Many people share projects that demonstrate a particular technique and encourage others to use it in their own projects.

I am very impressed with the projects on the Scratch web site. There are over 32,000 projects as of this writing, which is impressive since the program only came out in May of 2007. Some projects are artistic perhaps using color cycling or other graphic effects to make their pictures come to life. Some are animated stories. Some are musical. Some interactive. There are plenty of video game style projects ranging from imitations of classics like Pac-Man or Donkey Kong to original ideas. There are projects exploring science and math and many show a great deal of sophistication.

The usability of the development environment is superb. It is well organized and intuitive. It is also visually attractive. What I find most impressive, for such a new product, is that it is rock solid. I used it a number of hours over the course of a week often leaving it running for days without a single crash, glitch or loss of data.

Programming is done by putting together statement blocks such as Scratch Move Block and control blocks such as Scratch Repeat Block. As far as I can tell it is not possible to get an error message no matter how you put the blocks together. It may not do what you want but it will not complain that you did something wrong. Feedback is immediate. Just double click a block to see what it will do. Another great feature is that you can change your program while it is running.

Scratch is implemented in squeak. When the projects are uploaded to the web site they run as a Java applet. I have noticed some differences between the behavior of my project when run in Scratch and as an applet but the differences are minor. Probably just display glitches in the Java graphics routines.

How about the Scratch language itself? Well from an experienced programmer’s point of view the language is extremely limited. For example, variables can only hold numbers, there are no string manipulation operations, and there are no arrays or collection data types. Not surprisingly the programs are event driven. Groups of statement or control blocks are run when the start flag is pressed, a key is pressed, when a sprite is clicked or when a message is received. Messages are broadcast and all handlers act on the message. You can define as many messages as you like. Messages cannot have arguments which is one of the most limiting things. The message handlers are the closest thing to a subroutine but because there is no argument passing all information flows through global variables. I would say that it is a strongly typed language in the sense that the round edges of a numeric value will not fit where the sharp edges of a Boolean expression are expected. Variables must be declared.

Simple things like prompting for a name and then outputting "Hello " + name is very difficult due to lack of input/output and string manipulation primitives. However things that would be complex in other environments like hit tests between two moving sprites are trivial. I had to remind myself that I am not their target audience and everything left out was probably left out for a good reason – usability.

I am not a big fan of graphical programming languages. I quickly got tired of the Lego Mindstorms block programming language and switched to NQC. I found the Mindstorms programming environment to be slow, noisy, and inefficient. All of the graphical programming languages I have ever tried I found to be far inferior to text. Scratch is no exception but it is the best interface I have see yet. I also think it is just the right thing for young kids. Having visual blocks to move around really maps well to the physical world they are used to manipulating.

I do hope the language gets extended. I would like to see advanced users be able to explore programming concepts such as recursion.

Like I said, its not just my kids that find Scratch compelling. I wanted to play with it as well. I rationalized that by learning it I would be better able to help explain it to my kids but I like creating things no matter what the medium.

My first project is Addition Tutor. It is an interactive program to learn and practice addition of up to 3 digit numbers. I decided on this project because of the challenge of inputing and displaying numbers in Scratch and because it is something that I’m teaching my kids now.

Scratch Project

Scratch is not the first programming language with kids in mind. Way back when there was Logo and more recently KPL. I took a quick look at KPL and it looks like visual basic to me. Unlike Scratch there was nothing enticing me to try it out. The first thing you may ask about a language is what can I do with it. What better way to answer that question than with a web site with thousands of examples all of which you can download and try.

Lego Marble Machine

I don’t know what it is about this one but I like it. It sits on my desk and every now and then I turn the crank or run the motor and just watch the marbles go round. It’s fun. It’s hypnotizing. It’s pointless.

A few months ago my kids and I were building with Legos and making marble runs for the Geomag marbles. I started thinking about different ways to get the marbles raised up. I remembered seeing a device not too different from the one I built but made out of wood. I saw it in a craft fair years ago and although I never saw it in motion I knew what it was for and how it worked. I thought of making my own out of wood but so far have not. Think of this Lego machine as a prototype for … Well that’s a project for another day.

It is made out of various Lego, Technic, and Mindstorms kits except for the metal Geomag marbles. The yellow and green rails are from one of the Mindstorm add-on kits. There is no programming to this one. The programmable brick simply runs the motor which I turn on with the remote control. Alexandria and Isabella made the minifigs and Yoda’s hut. I added them to the video to liven it up.

I have wanted to try out YouTube for a while now and sharing the marble machine seemed like a good way to do it. I’m no musician but I think it is important for videos to have a sound track. For my home videos I usually use music from my CD collection. But because this one was going public I decided to see what Creative Commons had to offer. From there found “Fault in the air” by DJFer. The video was made with my old Sony digital 8MM camcorder. For editing I use Adobe Premiere.