Getting FFmpeg on windows

All the guides to getting ffmpeg working on windows seem to be extremely outdated; so here is a quick howto:

  1. Download mingw
  2. Install mingw with MSYS option; it will download and setup in C:\MinGW
  3. Get the mingw coreutils extra package (can be found from here); current version
  4. Install the coreutils extras package by un-7zipping and un-tarring it to C:\MinGW\msys\1.0\bin
  5. Download yasm; save it as C:\MinGW\msys\1.0\bin\yasm.exe
  6. Download and extract ffmpeg source (I used revision 647ec6f)
  7. Edit your C:\MinGW\msys\1.0\etc\fstab file to add the location of your ffmpeg source
  8. Open MinGW shell (it should be in your start menu)
  9. change to the directory you extract ffmpeg (going via the alias you added in fstab)
  10. ./configure
  11. make

HTML generation with lua

In my adventures on the web; I discovered an aid for writing HTML called zen-coding. Playing a bit with it, I found it lacking in some departments, and began to think that macros aren’t whats needed, but complete generation.

I remembered seeing an example of some html generating lua code a while back, and for a bit of fun decided to do my own take on it…

local function renderattributes ( attr )
    local t , i = { } , 1
    for k , v in pairs ( attr ) do
        t [ i ] = ’ ‘
        t [ i + 1 ] = k
        t [ i + 2 ] = ‘=”’
        t [ i + 3 ] = v
        t [ i + 4 ] = ‘”’
        i = i + 5
    end
    return table.concat ( t )
end

local function tostringtable ( t )
    local r = { }
    for i , v in ipairs ( t ) do
        r [ i ] = tostring ( v )
    end
    return r
end

local elementmeta = {
    __tostring = function ( t )
        if #t == 0 then — Self closing tag
            return “<” .. t.tag .. renderattributes ( t.attr ) .. “/>”
        else
            return “<” .. t.tag .. renderattributes ( t.attr ) .. “>” .. table.concat ( tostringtable ( t ) ) .. “</” .. t.tag .. “>”
        end
    end ;
}

local escapecodes = setmetatable (
    {
        [“<”] = “&lt;” ;
        [“>”] = “&gt;” ;
        [“&”] = “&amp;” ;
        [‘”’] = “&quot;” ;
    } ,
    { __index = function ( t , k ) return string.format ( “&#%03d;” , string.byte ( k ) ) end }
)

local function escapehtml ( str )
    return ( str:gsub ( [=[[<>&”]]=] , escapecodes ) )
end

local stringmeta = {
    __tostring = function ( t )
        return escapehtml ( table.concat ( t ) )
    end
}

local function construct ( tag , contents )
    local attr = { }
    local r = { tag = tag , attr = attr }

    for k , v in pairs ( contents ) do
        if type ( k ) == “string” then — attribute
            assert ( type ( v ) == “string” , “Attributes must be strings” )
            attr [ k ] = v
        elseif type ( k ) == “number” then — Contents
            if type ( v ) == “string” then
                r [ k ] = setmetatable ( { v } , stringmeta )
            elseif type ( v ) == “number” then
                r [ k ] = setmetatable ( { tostring ( v ) } , stringmeta )
            else
                r [ k ] = v
            end
        else
            error ( “Bad type” )
        end
    end

    return setmetatable ( r , elementmeta )
end

local CDATA = function ( p ) return setmetatable ( p , { __tostring = function ( t ) return “<![CDATA[” .. table.concat ( tostringtable ( p ) ) .. “]]>” end } ) end
local javascriptblock = function ( p ) return construct ( “script” , { type=”text/javascript” ; “//” ; CDATA { ‘\n’ ; p ; ‘\n//’ } } ) end
tags = setmetatable ( {
        CDATA = CDATA ;
        javascriptblock = javascriptblock ;
    } ,
    { __index = function ( t , k ) return function ( p ) return construct ( k , p ) end end }
)

To be used like so:

setmetatable ( _G , { __index = tags } )

print ( html {
        head {
            title { “Text” } ;
            javascriptblock [[alert(“XHTML compatible!” );]] ;
        } ;
        body {
            div { id=”main” ;
                img { src = “blah.jpg” };
            }
        }
    } )

Output:

<html><head><title>Text</title><script type=”text/javascript”>//<![CDATA[
alert(“XHTML compatible!” );
//]]></script></head><body><div id=”main”><img src=”blah.jpg”/></div></body></html>

The code is quite extensible, to create a new tag/block, all you need is a table with a __tostring metamethod.

Contrary to first appearances, it doesn’t just create a document from a table, but creates an internal structure of a document; which can then be generated on demand (via the recursive __tostring metamethods). This means that dynamic content can be used with the same structure:

userloggedin = function () return true  end
function loggedinonly ( p ) if userloggedin() then return setmetatable ( p , { __tostring = function ( t ) return table.concat ( tostringtable ( p ) ) end } ) else return “” end end
print ( body {
    loggedinonly {
        div {
            “Logged in!”
        }
    }
} )

Obviously, to facilitate writing conditional code easier, some simple helper functions can be created:

setpassthrough = function ( t ) return setmetatable ( t , { __tostring = function ( o ) return table.concat ( tostringtable ( o ) ) end } ) end

function ifcond ( cond , t , f )
    if cond then
        return setpassthrough ( t )
    else
        if f then
            return setpassthrough ( f )
        else
            return “”
        end
    end
end

Maybe when I need to write some html I can put this into practice!

If you find this useful, please give me a yell!

Tags: lua coding html

Motorbike annoyances

So I finally got my GSXR-400 back together on friday, after taking it apart three months earlier for a service… And I hear a valve that isn’t correctly adjusted. Now I have to take the tank, fan and engine cover off again to readjust a valve clearance :(

Tags: motorbike

Costumes

Yet again I am leaving a costume to the last minute… For eng ball on Wednesday night the general theme is “Hollywood”; but each table has it’s own sub-theme.

Our Theme: Toy Story.

I expect I’ll end up going as Woody cause its the easiest…

Tags: social

How GHDL is awesome

So, for a subject at uni (Digital System Design), we have to learn and use vhdl. Not the best language ever invented (who the hell bases a language on Ada anyway…. ew), but I suppose it gets the job done.

We learnt using modelsim and quartus on the uni computers, and from the very start I thought they were terrible, terrible programs. Modelsim seems to freeze regulary during simple tasks, highlighting leaves much to be desired, compiling is extremly awkward and half the time was spent trying procedures in a slightly different order to get things compiled/running.

The other night while at home I decided to give the GHDL suite a go, and god am I glad I did. Being able to debug in several steps was a great improvement, and gtkwave is a great waveform viewer, or at least it is for all the assignments we get for this subject. No longer do I have to use uni computers, or use the expensive ugly beast that is modelsim.

I sort of enjoyed working in vhdl for a little bit there…

Tags: uni vhdl

Easter Update

My current symbol of easterI’m not so into this blog thing… Wonder if anyone ever even reads this stuff.

Easter has come and gone, with a mild amount of chocolate digested. The birth of zombie jesus was remembered by some, for others, easter just brought an overwhelming amount of advertising about rabbits with eggs came into their lives.

Anyway, latest and greatest is a dead hard drive(s), having lots of fun getting that going again. ddrescue to the…. rescue. Hopefully haven’t lost anything; recovered all of my boot drive, but another drive isn’t as lucky it seems, though its only stopped working after I fixed the other one!

A slightly more screwed hddIn other news; uni is always looming, hardly get any time free. Engineering mechanics is quite hard, and not the best taught subject around… Not sure how well that will come out in the end; calculus 2 is making alot more sense the second time around, probably a good thing, though it is a trudge, and I would much rather to be back in linear algebra. Engineering computation is quite easy, but I’m still getting a bit out of it, my C programming skills are less of a hodge podge, a few syntaxy things are now a heck of a lot clearer.

Wish I had some pictures or something, this page is so bland…. (ok, added some, yay relevance)

Boxing Day Update

Ok, well, the new linux install failed, couldn’t get it to boot from grub no matter what I did. Shall leave THAT problem for another day.

In other news, I’ve finally replaced my iphone. It has been replaced by the lowly nokia 7210, and (to be delivered shortly) a sansa fuze.

The Nokia 7210 SuperNova is quite a nice phone, and for only $159 (from AllPhones), its quite the bargain. Only a Series 40 phone, but thats all I need. Only thing I miss is wifi, I liked sshing in to my comp from random places :P Would now cost a fortune over gprs. I’ve already mistakenly clocked up $13.86 in GPRS charges, it seems that its $1.32 per something - more than a minute, and can’t be more than per 10KB….. Trying to figure out how to disable it permanently on the phone, and even get it barred on the carrier side. So far have found no relevant menu options :(

With any luck, I’ll be able to get rockbox going on the fuze, but thats still to be delivered (and investigated).