Friday, October 24, 2014

HandBrake Video Conversion Software

I've been working in my spare time recently on finishing up my Excel smart search app, and today I got to the point where I wanted to show it off to some friends. The problem is that it turns out it's rather difficult to find free software that also doesn't have malware, when it comes to screen capturing and converting video formats.

For capturing the video in the first place, I ended up going with a program called HyperCam 2. It's not the best software in the world, and it's not open source. It is free, though, and it works for what I need for the moment. One small problem with it is that it outputs in fully uncompressed AVI video. For a 2 minute video at 720p, we have a file that is 250MB. I began looking around for conversion software.

When you google "avi to mp4", you get a massive list of really crappy software which either costs money, is loaded with malware, or both. The problem is that these sites have gotten very good at SEO, and even places like cnet's doesn't really scan them well. On further research, though (involving actual forums), I found an program called Handbrake, and it's absolutely wonderful.

Handbrake is an open source project housed at It's a very small download, and it installed in 15 seconds (including the time it took me to click Accept Terms). It has a pretty simple interface. You select the source file, select the location and name of the new file. You choose what format you want to convert it into, and then click Convert. It took about 20 seconds to convert my 2 minute video. And file size went from 250MB to 5MB. That's a rather incredible reduction. (Granted, I did select Optimize for Web, and the new video is just very slightly more blurry because of that. When I didn't optimize, the video ended up about 30MB). See the screenshot below to check out what it looks like.

As someone who has written several WordPress plugins that I let people use for free, I very much appreciate kind words from someone who benefits from them, and in turn I try to give positive feedback for freeware that I benefit from myself. Hence this post. HandBrake is lightweight and works like a charm, plus it's malware free. Give it a try next time you need to convert video.

Thursday, September 11, 2014

How Far We've Come in 13 Years

It's been 13 years since extremists attacked the USA. 13 years, and the world seems just as dangerous as it was before. The heady days of the Arab Revolution, when waves of democracy and popular rule were sweeping the middle east, are long gone. Egypt is back where is started, Syria never finished falling in the first place, and Libya is in the middle of a new civil war. Not to mention ISIS. Oh and Ebola is slowly decimating Africa, country by country.

But consider this. Osama Bin Laden is dead, along with nearly every senior Al Qaeda commander from the time. The new World Trade Center building is almost complete. Unemployment is getting close to falling under 6%, and the GDP is up. Plus technology marches on. Direct brain to electrical connection, internet so fast you could download the Library of Congress in minutes, fully electric cars which go hundreds of miles between charges, and even reusable rockets which can land vertically, all coming down the pipeline.

The world is in a race. A race between technology and entropy, and I speak of entropy metaphorically. Entropy is the forces of chaos, the forces of destruction. Extremist religion (of all flavors), global climate change, diseases such as Ebola, poverty, and even just the natural slow progression of all governments into totalitarianism.

And it isn't new. History and human civilization are cyclical. The forces of chaos knock everything down, and then we slowly rebuild. We get knocked down, and we rebuild. 1200BC, 500AD, both times civilization collapsed. But each time, we retained more technology than before. The only question that remains is how far we can get before the next collapse. I have high hopes. I look around and see how fast we are progressing, and I think we can beat it. I think that my generation can be the first to permanently colonize something that isn't on Earth. We we can spread out, we can finally break the cycle, and then how far do you think we'll go?

Wednesday, September 10, 2014

Text in SVG: 3nd Attempt (Size Reduction)

Several days ago I wrote about finally solving the text in SVG problem. The key was to pick an open-source font, obtain the woff and svg font files, convert those files into base64 data streams, and plop the whole thing inside the actual SVG itself. And it works!

Problem is, I overlooked the file size. My original PNG logo file is 20KB. The new SVG is 400KB. That's 2000% increase in size! And completely unacceptable to me. I set out to find ways to decrease the size.

My first find was the tspan element. This is an element, similar to HTML's span, which can be embedded in a text element. Instead of having a new text element for every enlarged letter, I can just wrapper those letters in a tspan element and use CSS to apply the font. This helps in rendering time, but unfortunately doesn't significantly change the file size (409KB to 408KB).

I then tried removing whitespace. It screwed up the file and didn't really save space.

My final idea was to look at the cause of the large size. The current SVG had both an SVG and WOFF font file embedded. Looking at the font size, it turns out that the SVG font files were huge. 120ish KB each, for the two fonts I'm using. And an SVG font is readable if one opens it in a text editor. It's kind of odd to look at, but I found a pattern, and I found saw each letter and typical character. I simply removed all characters that I'm not using for the logo. Doing this for both fonts and reencoding in base64 netted me a huge size reduction. The SVG logo is now down from 408KB to 120KB. That is still far larger than 20KB, but it's a gain I can live with given the sharpness benefits of SVG.

This does mean that if the text ever changes in the logo, I'm going to have to go back to my original font files and add or subtract certain characters. But the text is a company name, meaning it won't change often. I've texted in Chrome and Firefox on Android, along with Chrome, IE11, and Firefox on Windows. Take a look at the 408KG and 120KB versions below:

SVG 408KB:

SVG 120KB:

Monday, September 8, 2014

Text in SVG: 2nd Attempt

Last week I attempted to convert a complex logo involving text into SVG, and failed. This was due to the fact that the logo in question used Palatino Tinotype, which is a font that seems to be completely safe because it's installed on all Windows and OSX machines. However, this is actually not an open source font, and Android phones don't come with it. The logo ended up using the default serif font for Android, which messed up the spacing and looks quite terrible.

Additionally, Chrome on Android doesn't support the CSS selector "first-letter", which I had been using to increase font sizes. I have since been able to address both of these problems. I split the "text" elements so that all first letters of increased size were in their own wrapper, which I applied a class to. Increasing the font size using this class works on all browsers. The font issue was more complex. The owner of the logo declined to pay $165 to buy Palatino Linotype, so I had to find a free alternative. After searching for a while, I came across TeX Gyre Pagella. This is a free font, and it looks extremely similar to Palatino Linotype. And so without further ado, I present the final product along with original PNG for comparison:


Original PNG:


It turns out at at the time I posted this, I was STILL missing something. When SVG files are embedded, they can't have any external dependencies. This includes referencing fonts. I therefore had to convert the fonts to a data URI stream. To be entirely honest I have no idea how it works, except in concept. It takes the entire file, converts it into a special text language, and I insert that text blog into the spot that I'd put the font address. I found a very nice tool, which let me upload the font files.

One issue I now see is that the SVG file is much larger. We are talking 400KB instead of 5 or 10. This somewhat destroys a large advantage of SVG in the first place, which is the smaller file format. However, it retains the perfect sharpness at all sizes, which is worth it. I've edited the file which is previewing above, so it should look great on all devices, finally. If it doesn't on whatever you are viewing it in, please let me know!


Turns out that IE9-11 screws up the SVG if it is resized. This is because IE requires an extra attribute on the SVG element, called "viewbox". Since my SVG width is 1220 and height is 200, I have to add this: viewbox="0 0 1220 200". More information here.

Sunday, August 31, 2014

Downside of SVG - Fonts

My third attempt at conversion to SVG is a logo with text. I spent about 4 hours doing it, because it's got 16 different SVG elements without counting the linear gradients (which are creating using elements instead of CSS it turns out). In the end, it looks really great, and the text resizes smoothly in a way that you normally requires javascript:


Original PNG:

Here's the thing. If you are reading this post via a Windows or OSX -based PC, then the two should look almost identical. If you are using Firefox on Android the same will apply. However, Chrome, Dolphin, and the Android browser itself, will all render this incorrectly. See the comparison below. The top is Firefox for Android, the bottom is Chrome on Android:

The problem is that the font I'm using is Palatino Linotype, which ships default with Windows and OSX (and somehow Firefox for Android??). Chrome doesn't have it though, and so pulls in the default Chrome serif font. It's thicker and so looks too big.

All of which leads me to a fundamental problem of SVG, which is that it's not prerendered, and because of that it relies on the browser having all rendering resources. If you notice in the comparison, there's another problem. The first letter of each word isn't a large size in Chrome. This is because Chrome doesn't support the CSS rule "first-letter" for SVG text elements. As I take SVG into more complex situations, I'm becoming less sure it is really read for primetime. Which is sad, because when I compare the SVG and PNG versions of this logo on my phone, the clarity difference is striking. I just have to find workarounds to all the things that Chrome is screwing up.

In regards to the font-face, I just need to embed the font or have the SVG pull from a hosted source. If one is using a commercial font, however, one runs into issues. Palatino Linoype costs 150 bucks, so for this particular logo I'm out of luck (unless someone knows a free alternative that looks close enough that most people won't tell the difference??). It can be mitigated by using open-source fonts. As to the first-letter issue, the alternative is to split the text elements into more text elements and apply the large size via classes.


I've started a StackOverflow question about workarounds to the first-letter issue. Hopefully someone will have a clever idea.

Monday, August 18, 2014 SVG Feature Request Update

Less than two weeks ago I submitted a feature request to, for the ability to embed a 'pen as an SVG image. Not only did they respond within a few days saying that they'd add it to their list, they actually got it working .... in less than two weeks. Take a look at the logo I converted to SVG a few days ago, emdedded below from CodePen. It looks and acts like a simple image. This is how I'd be calling it in a production site, as an image. It's really easy now to compare the difference between the two image types:



(Displayed at native resolution)

Now, if CodePen could add the ability to take snapshots and version history like JSFiddle does, I'd have everything I need in one service and wouldn't have to use both.

Sunday, August 17, 2014

Shift In Focus

Over the years, this blog has been somewhat of a scattershot of topics. Initially, it had a very political/civil liberties focus, but that branched into more theoretical topics, such as ethics and philosophy. As I moved into web development, and WordPress, those became topics of greater frequency. And scattered throughout have been posts on music, humor, and even poetry I've written.

You may have noticed that I haven't posted much about politics for some time, and the reason is that politics has become increasingly depressing to me. We live in a society which increasingly embraces constant surveillance, in which we daren't videotape a police officer out of fear of retribution. A society in which we can be sent to prison for shooting a home intruder who invades without a warrant or even warning, just because they happen to have a badge and made a mistake on the address. There are some bright spots. Marriage equality has won. The falling tree may not have hit the ground, but gravity took over years ago and the conclusion is foregone. But in almost all areas, the world has become a scarier and more depressing place.

I also don't write about civil liberties as much, because I have grown increasingly disillusioned and fed up with all sides. It is absolutely wrong to judge someone for the color of their skin, or for the person they love. But that cuts both ways, and as someone who has been judged for being a white male by my supposed allies, my willingness to get involved has decreased over time. Yes, I understand that I have white privilege, and any automatic judgement I get for my skin is nothing compared to the judgement that a transgender person of color gets. But time and time again I see a level of automatic hate coming from the non-cisgendered community that almost approaches the level of hate (that I've fought against) from the fundamentalist religious faction.

Which brings me to my final point. What I HAVE been writing more about recently is code. The beauty of PHP, of HTML, of CSS ... is that they are languages of utter and complete honesty, and logic. If you write something, it's either correct or incorrect. There's no debate, there's no hatred. Certainly people might have differences of opinion on best practices, or what browser to use, but in general it's a much more pleasant area to spend my time in. Additionally, the communities are some of the least judgmental communities that exist. No one cares about who you are or what you look like. If you can write good code, or design great UX, or even just come up with good ideas ... that is all that matters. WordPress contributors are from all around the world, and almost no one brings their societal/cultural baggage with them. Code is king, and I like code.