Posts for the 'Computing' Category

  1. HTML5 video support

    At Cantemo for our Portal product we are working a lot with HTML5 video, its starting to get really nicely supported by all the major vendors and we have some nice technology to support frame accurate playback, frameforward and frameback on a lot of browsers (Chrome, firefox, Safari etc).

    This puts us in a much better position than we have had in the past with h.264 playing back through the Flash player (though this is a fallback mechanism still).

    Trouble is we have to implement support for different codecs, for the different browsers. Our software supports this out of the box, but it means that we have to do some interesting detection of browsers, formats that we have, and offer a plugin solution. Today we can transcode to OGG, WebM and h.264 with no problems, and then match this to browsers:

    Here is a table of what browsers support which video formats:

    HTML5 video format support
    Browser Ogg h.264 (mp4 extension) WebM Notes
    Safari * 3.0+ * *Safari will play what Quicktime supports
    firefox 3.5+ Use flash. 4.0+
    Chrome 5.0+ 5.0+ 6.0+ h.264 will drop soon, still works as of 12
    Opera 10.5+ Use flash 10.6+
    IE - 9.0+ 9.0+* *Only works with optional plugin

    This table assumes that h.264 is in an MP4 wrapper, with an AAC codec for sound. OGG is encoded using Theora, with a Vorbis audio codec.

    By timc3 on the
    August 6th, 2011
  2. Quick update

    Haven’t had much time recently to post anything on here, though lots has been going on that I could write about.

    Been to Cyprus for a family wedding which was really nice, pity that we had some stuff stolen including my iPhone, Nikon DSLR and video camera but otherwise it was great.

    At work we are building new HTML5 based tools, improving the look and feel and capabilities of our main product – should really write up about some of the technology being used. To quickly list – backbone.js (which I love), gunicorn, Eventlet, some more nginx tricks, been building .deb installers, Python configuration tools, Johnny Cache for Django, Celery delayed processing and some more bits and pieces.

    By timc3 on the
    June 14th, 2011
  3. Resizing ext3 or ext4 partition for virtual image

    Note: please backup and make sure that you have a copy of your data and virtual images, this can go wrong and I won’t be held responsible. This worked for me, and might not work for you. For ext4 please use the latest GParted.

    As I migrated from raw or qcow images, some of the partition sizes that I have to work with are not as big as they could be. So I need to resize.

    I generally give some of my hosts a 24Gb LVM virtual group each. But the image files can be as small as 2Gb – A lot of wasted space which the filesystem on the image might as well have. These instructions assume that there are only two partitions, a main partition, and a second Linux swap partition (either on an extended partition or a primary).

    First taken the image offline, then get the name of image that you wish to resize, then the disk storage items:

    ls /etc/vm/
    lvdisplay

    In my case it was “/dev/vdisk05/vm-102-disk-1″. Then you can check to see how large the volume group is set to (vgdisplay) resize:

    lvresize -L 23G /dev/vdisk05/vm-102-disk-1

    Next I mount a SystemRescueCD on the CDRom, and make sure its the first item in the boot sequence. Then boot into the system, go for the first choice in SystemRescueCD, and it will give you a rootprompt (I am VNC’ing into the system so that I can access the console as if using a physical machine):

    #Change the passwd so that you can ssh in if you need to.
    passwd
    #Start the GUI so you can run Gparted (First choice again).
    wizard

    From a command prompt do (check file system, repair, remove journal):

    1. fsck -n /dev/sda1
    2. e2fsck -f /dev/sda1
    3. tune2fs -O ^has_journal /dev/sda1

    Then do the following in the GUI:

    1. Choose CD > System > GParted
    2. Delete the swap partition as it will be the last
    3. Resize partition, leaving some space for a new swap partition
    4. Create a swap (type Linux-swap) partition twice the size of the amount of RAM you allocate to the image
    5. Click Edit > Apply all operations
    6. Close GParted

    Back on the command prompt do (repair, check file system, journal, shutdown):

    1. e2fsck -f /dev/sda1
    2. fsck -n /dev/sda1
    3. tune2fs -j /dev/sda1
    4. shutdown -h now

    Remove the CDRom device, and change the boot order back then start the Virtual machine. Issue a df -h to see if the partition has changed. It should have done!

    By timc3 on the
    May 2nd, 2011
  4. Virtual host QCow convert to LVM

    Sometimes its better to have your virtual images running directly of LVM instead of using raw or QCow formatted files. So how do we convert? Basically you have to make sure that you have a volume group, of the right size or bigger and then dd the file into a LV on that volume group:

    This should in the directory where you have the image:

    # Get the filesize of the raw image in Kilobytes.
    ls -lk
    #Create lv on vdisk05 (the VG)
    lvcreate -L 5242880K -n vm-102-disk-1 vdisk05
    #Convert from QCow to Raw
    qemu-img convert bld-ubuntu-1004-2.qcow2 -O raw bld-ubuntu-1004-2.raw
    #Copy the image into the lv:
    dd if=bld-ubuntu-1004-2.raw of=/dev/vdisk05/vm-102-disk-1

    Then change the configuration of your QEMU or whatever you are using on your virtualisation platform.

    Sorry for the briefness of the instructions, its mainly for my own benefit and if you are doing this you should really know about LVM, dd and ls.

    By timc3 on the
    May 1st, 2011
  5. Webcasts to watch

    Recently I was unfortunately quite ill and away from work for an extended time, the only upside being that I had some time to spend learning some new things and watching web conferences on my Apple TV2. Of those that are of interest, I am going to note them down here:

    * LeWeb – Really quite good, european focused web event
    * PyCon 2011 – A must watch for anyone using Python.
    * JSConf – Good Javascript conference, though I got the feeling that it wasn’t quite as friendly as Pycon.
    * Webstock – New Zealand conference.
    * Future – Some interesting interviews.
    * Google Techtalks

    Of course I also watched quite a lot of Ted videos.

    I will keep adding to this list as I find more events to add, as there must be quite a few now.

    By timc3 on the
    April 15th, 2011
  6. My Jenkins nginx proxy script

    Here is a very simple configuration for nginx to proxy Jenkins (the new name for the un-Oracle’d Hudson)

    server {
            listen   80 default;
            server_name  bld-master localhost;
            root /var/lib/jenkins;

            access_log  /var/log/nginx/jenkins.access.log;

            location / {
                    proxy_pass        http://127.0.0.1:8080/;
                    proxy_redirect    off;
                    proxy_set_header  Host             $http_host;
                    proxy_set_header  X-Real-IP        $remote_addr;
                    proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            }

    }
    By timc3 on the
    April 15th, 2011
  7. Setting MAC Addresses on Debian and Ubuntu

    I recently had a problem with having duplicate MAC addresses on my network for a couple of machines that I was using in a Linux KVM cluster. Flashing the firmware on the motherboards seem to have reset the MAC address to a default (thanks ASUS) that was the same on each board.

    Changing the MAC address back seems like quite a hard job and looking around on the internet it seems that many people are doing this the hard way with shell scripts and so forth. Instead its easy enough to do this using the scripts that are already setting up the network for Debian (and I am sure this will work for Ubuntu just as well).

    Edit /etc/network/interfaces like so:

    auto eth0
    iface eth0 inet manual
    pre-up ifconfig $IFACE hw ether 00:01:02:03:04:05
    pre-up ifconfig $IFACE up
    pre-down ifconfig $IFACE down

    What this is doing is manually controlling the startup and shutdown of the eth0 interface. I am using bridging on my KVM boxes, so I don’t actually have to set up the IP address (albeit DHCP or manual IP configuration), but that aside the interesting parts are what happens in pre-up. Firstly I set the hardware address to a new address (and please change it from the example above – thats not the actual one I used either), then we tell it to bring the interface up.

    We also use pre-down to tell it what happens when stopping the network service.

    Probably better than messing around with Shell scripts.

    By timc3 on the
    April 14th, 2011
  8. WebM/VP8 and H.264

    This is probably the best over article on the whole WebM/VP8 and H.264 issue:

    http://antimatter15.com/wp/2011/01/the-ambiguity-of-open-and-vp8-vs-h-264/

    Well worth a read.

    By timc3 on the
    January 19th, 2011
  9. Django Select Multiple filter.

    Django has a really nice select multiple field, for choosing multiple items at once with a Javascript chooser..

    It is really handy to use when there is a large number of items that have to be chosen from in a select. I am using with JQuery.

    To do this, grab SelectFilter2.js from the django-admin media folder, or get it from Django’s GitHub repository. Then to initialize it you can put the following into your code:

    $(document).ready(function() {
        $.each($("select[multiple]"), function () {
             // "Locations" can be any label you want
        SelectFilter.init(this.id, "Locations", 0, "/media/");
      });
     });

    This will use the SelectFilter on all select multiples and give it a label of locations.

    For reference the functions are:

     function(field_id, field_name, is_stacked, admin_media_prefix)

    So you could use:

     SelectFilter.init("#MySelect", "Test", 0, "{{ MEDIA_URL}}img/");

    Then all that needs is styling the select multiple.

    By timc3 on the
    November 2nd, 2010