Evil Evil Video

In fantasy land I can just copy video from a camcorder, upload it, and I’m done right? Nope! HTLM 5 attempts to solve the problem with the new video tag. But some people (Apple) want to use various MPEG files like H.264 for HTML 5 Video. Well that isn’t practical.

My work deals with videos. I take them from DV tapes to viewable, downloadable video on a website. In fantasy land I can just copy video from a camcorder, upload it, and I’m done right? Nope! HTLM 5 attempts to solve the problem with the new video tag. But some people (Apple) want to use various MPEG files like H.264 for HTML 5 Video. Well that isn’t practical. Yes H.264 is a good format. H.264/MPEG-4 have patents and users must pay a fee to use them. Distributing them with say Firefox, isn’t possible. Second lets say someone paid a lot of money to allow it’s distribution. I can’t redistribute software that encodes MPEG4 for free (legally). So my client’s can’t transcode their videos. Do I tell them oh just send a check too…yea right.

There is a solution hack
Ogg Theora It handles video great and has a quality to disk space ratio competitive to H.264. It also handles shaky camcorders better which is huge for what I do. I can easily make a script with ffmpeg2theora that converts dv to ogg theora. I use virtualdub for extracting the DV tape video and avisynth for editing if anyone is curious. Now it’s easy to convert a large avi into a much smaller ogv file ready for uploading.

Next the server runs cron jobs to encode it as flv flash and MPEG1. MPEG1 is sometimes requested by the same companies that run Internet Explorer 6 with no plans up updating it ever. Flash if for backup since most people won’t have a browser than can play HTML 5 video. Since the flash video in my case is only for previews really, I can drop it’s quality big time so the flv file doesn’t chew through disk space. MPEG1 quality is dropped too because MPEG is horrible. Only a few clients need it so tough they get low quality. I play the flash with FlowPlayer and play the video with something like this
<video src="file.ogv" >
Play flash with flowplayer if html5 video fails.

Now if fully digital camcorders would get cheap, we could stop using those intensely annoying DV tapes.

Teaching programming part 2

Ok here’s my favorite program to play with for teaching children their first lesson
// Simulate the world being destroyed (or prospering)
using System;
namespace worldsim
class MainClass
public static void Main(string[] args)
// Number of life forms on Earth
int people = 400;
int animals = 300;
int plants = 500;

int day = 0; // Days past since start of simulation
int maxDay = 100; //

// while days not maxed and there are more than 0 people
while(day 0)
people = Convert.ToInt32(Convert.ToDouble(people) * 1.02);

animals = Convert.ToInt32(Convert.ToDouble(animals) - (Convert.ToDouble(people) * 0.1));

if (animals < 0)
animals = 0;
// Starving people
people = Convert.ToInt32(Convert.ToDouble(people) * .9);


// Show daily populations report
Console.WriteLine("day: " + day);
Console.WriteLine("people: " + people);
Console.WriteLine("animals: " + animals);
Console.WriteLine("plants: " + plants);

I just give this code to everyone after briefly explaining a few basics of programming, introducing them to a terminal, etc. Programming in crazy. You can’t just learn it quickly through lecture; you learn by doing. This program is a primitive world simulation where humans and other lifeforms exists, eat each other, and reproduce. By a few lines of code we can make the population explode, die out, or attempt to reach equilibrium. The Convert.Towhatever I say is evil magic for now and just copy and paste it as needed. Same with using System; The ; is evil magic too, designed to make programming hard. The point is to have fun. You know its working when kids start coding in lines that contain words they think you would yell at them for writing. The best part is you see how each student learns almost instantly! Some will do exactly what you tell them and try to make a persistent where all the creatures co exist. Some will work together while some will turn to you for help. Now you can cater to each type. The students goofing around thinking they are 1337 haX0rs making flying pizza’s attacking digital humans while want more challenges and must be allowed for creativity, else they will start playing video games. Others need some hand holding and more explicit direction before they get too deep into all this crazy programming jibberish. Either way is fine.

This program also makes a great lead-way to learn object oriented programming, since it’s easy to make people into objects with methods like eat, reproduce, etc. But that’s later. Now they need to know how to program and what the “evil magic” is. This stuff is boring at first, but hopefully after seeing what programming can do they will be motivated for the task. Also I stay away from integrated development environments at least for a lesson or two. They teach kids to follow the evil magic of pressing buttons and suddenly the code works. This leads to treating code like witchcraft. They might start putting ;’s all over the place just to make it work, instead of figuring out why the ; should be there in the first place. That’s a bad habit that some people never break out of. They need to know what a complier, managed vs unmanaged code, and libraries are. Lectures about these topics are garbage if they know pressing F5 makes the program magically work, they will ignore you. Sure you could test them on knowing these buzzwords, but then they memorize instead of comprehend. So get in a terminal and compile! Make sure all the evil magic of programming is turned into understandable ideas.

Oh and one more thing, please don’t use the boring Lets Make a Calculator! program. Try to get feedback from kids and let them decide what they want to make. They are learning concepts, not how to make a stupid program that’s already been made 100,000 times before.

Teaching Programming Part 1

In my experience people generally teach programming poorly. A paper I wrote about this “Incorporating Gaming in Software Engineering Projects: Case of RMU Monopoly” will be in the next issue of http://www.iiisci.org/journal/sci/Home.asp

Summary – programming should be hands on and students should choose how to work, what to work on, and what tools to use. Instead students memorize how to write classes and learn about something they call objects, but don’t know why. Syntax is treated like witchcraft to make the program work and get an A. Also many professors are just boring and questionably interested in programming themselves. Others are arrogant and unapproachable. A good programming class lets students decide what they want to build. Lectures go over concepts and students then implement them how they see fit. Of course the instructor needs to be there to help them.

Some instructors seem to think students shouldn’t be allowed to look on the Internet for answers. That just crazy. At least 50% of my time at work is spent looking around on Google. Of course students in their first programming class may need a simple program to start with. Next week I’ll talk about how I teach programming.

The unbreakable Linux Desktop

A common need I find myself fulling is setting up a desktop that lasts forever without maintenance.  Ubuntu Linux doesn’t suffer from outside attacks generally (virus’s and such) but a 6 year old user is another story.  What we need is a desktop that limits user access while still allowing users to save documents and get work done.  The following things need done

  • Lock display appearance (theme, fonts, shortcuts, etc)
  • Filter Internet
  • Fully automatic updates

OK so obviously don’t give them root access, duh.  I’ve made a script to lock down the gnome’s appearance menu, gnome panel, desktop icons.
# Don't allow gnome appearance properties
sudo chmod 744 /usr/bin/gnome-appearance-properties
# Don't let users mess with the desktop
chmod -R -w Desktop/
# Don't let users mess with the panel
gconftool-2 --type bool --set /apps/panel/global/locked_down true

No more children changing the font size to 96pt!!  For filtering the Internet, I use Procon Latte, a firefox addon.  Procon works by looking at websites for bad words and blocking offending sites.  Now many computers need to access job sites which sometimes say something like Must be 18 years old to…  Yes that’s the same phrase used in many porn sites so it’s best to edit procon’s blacklist and remove phrases like that.  Also giving the administrator the password to procon and showing them out to put web sites on a whitelist is a must.  I try to stay away from installing wine too because of all the garbage users might attempt to install.

Ok locked down, now for updates.  Since the user doesn’t have admin rights they can run updates themselves.  The admin is too busy so forget that.  Ubuntu has an option for automatic updates, but it really means only security updates.  So I put this into cron.  At a terminal type sudo crontab -e  If you don’t know what vi or emacs are just press 3 for nano.  Now enter

0 3 * * * aptitude -y update && aptitude -y upgrade && aptitude -y dist-upgrade && aptitude -y autoclean

This runs truly automatic updates at 3am every night.  I would just disable automatic updates in software sources to keep it from annoying the user now.  Of course this only works while your ubuntu version is supported.  I suggest using LTS versions that are supported longer.  Usually an out of date configuration is the norm anyways so if you can’t come back to update, it’s probably fine.