HTML5 video on Android is not there yet

A couple of months ago I had to work on a project that involved setting up a video streaming website using the Brightcove service.

On desktop browsers, the default player would use a Flash interface, falling back to HTML5 videos on mobile. My development tests were run on my Nexus phone and tablet. All went well until I got the results from my QA team: the videos were playing only on Nexus devices. All the other phones were outputting the following error: “The video you are trying to watch is currently unavailable. Please check back soon.”

I spent a lot of time investigating this. Brightcove support was very helpful, and answered all my tickets with insightful information. Unfortunately, the conclusion was that there’s nothing that can be done regarding HLS videos on Android versions prior to 4.3. The fact that the BBC Good Food website somehow got it working makes me think that there’s a magical combination of encoding settings that plays properly on mobile. I don’t know how they managed to make it work; the email I’d send them remained unanswered.

I’ve summed up the content of the Android playback tickets I’ve raised with Brightcove, into something that might be considered an answer:

Changing the rendition selection behaviour for Android is going to be quite involved.

If you wish, you could use a player plugin for the time being to force all 4.x versions of Android to play HLS. The code at the link below uses the API to update the loaded video to use its HLS URL if available. https://gist.github.com/anonymous/29e94d6992d9105c7600 If you choose to use this you will encounter problems with Android < 4.2 when playing HLS, which is why the player prefers MP4 to HLS. The most problematic are that you can't seek, and playback stops and you'll get an error when trying to switch to full screen. There's nothing we can do in the browser to workaround these unfortunately -- these are problems with the device's HLS support.

There is no possibility of getting good playback on Android < 4.2 without Flash in the browser if you're using DRM. We can't improve Android's capability to play HLS in the browser, and there's no way to make an Android browser play DRM-encrypted MP4 renditions.

Android can play the unencrypted MP4 renditions, but if DRM is a must, you could consider the option of using a native app. Our Android SDK can play Widevine-encrypted videos, and there will be a version available in the future that uses a custom library to play HLS to overcome the shortcomings of Android's native HLS playback (in the app).

If anyone has had this problem and has found the solution, please let me know. A lot of people saw my Stack Overflow issues I’d raised, and I constantly have to turn down paid consulting offers that involve implementing HTML5 videos on Android.

Installing Ubuntu 12.10 on Lenovo X1 Carbon

Lenovo X1 Carbon Ubuntu

I recently purchased the Lenovo X1 Carbon as a replacement for my old, slow, and overheating laptop. I could have waited for the touch-screen version, but a Lenovo support guy told me on the phone that they didn’t know when it would be released in the UK, if ever. It took one month to get the non-touch Windows 8 version delivered.

As usual, Installing Linux on a new laptop proved to be more difficult than it should have been. I followed these steps to get it running:

1. Lenovo comes with a recovery partition instead of the Windows 8 DVD. If you’re planning on reinstalling Windows, it’s better to save the partition somewhere or back it up using Clonezilla. Deleting this partition saves around 15Gb of hard drive space. I haven’t had the need to use Windows since day one.

2. Because the laptop boots using EFI, it’s better to use the Secure Remix Ubuntu image.

3. Use LinuxLive USB Creator to build a bootable USB drive (it needs at least 2Gb).

3. Reboot and press F1 to enter the advanced boot settings. You have to disable secure boot and change the booting order to have the USB drive on top.

4. After the laptop boots from the USB stick, chose the option to install Ubuntu. I went with the installer’s default options, and I ended up with a 90Gb ext4 partition.

5. GRUB might need some fixing to make dual-boot possible, because selecting Windows 8 throws an error related to the EFI path. You can boot into Windows by changing the boot order, and moving Windows 8 on top of Ubuntu.

Apart from the fingerprint reader everything seems to be working. I successfully used Fingerprint GUI in the past, but it seems to be ignoring the X1 Carbon’s reader (although some people managed to make it work).

Another thing that bothered me was the Touchpad sensibility. While using the TrackPoint on Ubuntu (it works fine on Windows), when the palm of my hand touches the trackpad, the cursor moves. Because I don’t really use the trackpad, I disabled it using Touchpad Indicator.

Ubuntu runs smoothly, and I haven’t seen any crashes or performance hogs. It uses around 2Gb of RAM out of 8Gb, and the battery lasts for 3-4 hours of normal usage. I also tested the mini-display port on a HDMI and DVI cable, and it worked flawlessly. It rarely gets hot and you can barely hear the fans.

I don’t want to review the laptop, I agree with most of the pluses and minuses given by others. But one thing that I have to mention is that I LOVE the keyboard. I keep finding myself typing just for the sake of it. I knew Lenovo built a superior keyboard, but I wasn’t expecting to be that good.

Overall it is a solid machine and I’m quite happy with it.

24 hours is not enough

I haven’t posted in a while because I couldn’t find the time. There seems to be too little time to do all the things I want to accomplish.

Watching Scott Hanselman’s presentation, I realised I needed to let some things go. It’s tempting to be up to date with everything, but I just can’t do it any more. There’s a big difference between what I want to achieve and what gets done.

It sounds easy, but how can I simplify my life? What can be left behind?
I read a lot of RSS feeds. I was thinking if ignoring the articles would make any difference. Even checking the titles on a daily basis is time-consuming. I decided to read only some of them on my phone on the tube or before going to bed. I will get used to seeing the 1000+ count inside Google Reader.

I started using Pocket (Formerly Read It Later), but that didn’t worked out well for me. I ended up having over 200 articles saved in the queue. It’s still a great tool though. It seems like once you get rid of doing something online a new things comes up; now I’m spending too much time reading answers on Quora.

The web is an ocean, and I’m drowning.

Using Django with PostgreSQL

I recently switched from MySQL to PostgreSQL as the database engine for Django. The main reason for doing this is the PostGIS extension, which offers support for geographic objects. I’d thought it was going to be easy, but I encountered some problems.

The first step was to change the database engine in the application’s settings.py file:
'ENGINE': 'django.db.backends.postgresql_psycopg2'

Running python manage.py syncdb returned the following error:
Error loading psycopg module: No module named psycopg

I’d tried installing the psycopg2 package, but that resulted in another error:
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application

The libpq-dev package had to be installed to meet all the dependencies:
sudo apt-get install libpq-dev
sudo pip install psycopg2

But still, the syncdb command wasn’t returning the desired result:
Peer authentication failed for user "someuser"

I needed to open up the file /etc/postgresql/9.1/main/pg_hba.conf in a text editor (with root privileges) and change this line:
local   all             all                                     peer
to this:
local   all             all                                     md5

I had to restart the PostgreSQL server to load the new settings:
sudo service postgresql restart

Now Django should have a proper connection with the PostgreSQL database.

String concatenation operator in MySQL

I had been skimming through Bill Karwin’s SQL Antipatterns book when I saw this example:

SELECT *
FROM Comments AS c
WHERE '1/4/6/7/' LIKE c.path || '%' ;

This looked weird to me because I’d thought the || operator returns logical OR.

Even though the example made sense only if the operator joins the strings, I had to search for an answer online.
MySQL appears to support two forms of string concatenation. The one that uses the || operator (known as pipe concatenation) works only if you’ve added the PIPES_AS_CONCAT mode to your sql_mode variable and MySQL runs in ANSI mode.

Unfortunately you do have to use the CONCAT() function to make sure it works on all MySQL installations.