Speeding up search with Google Chrome

There are lots of reasons why you might like to use Google Chrome as your primary web browser:

  • It’s fast and lightweight (not too big to install)
  • It’s W3C-compliant (it’ll show web pages properly)
  • Based on the WebKit layout engine, it supports HTML 5
  • There are numerous extensions available for it
  • It’s highly compatible with Google’s other offerings, such as GMail and Google Calendar

Editing Chrome’s search engines

One very good feature of Chrome is that you can search fast by simply typing your search terms into the URL bar at the top of the browser. However, it isn’t always Google that you want to search. You might want to run a search on Wikipedia, Amazon, or another site. Wouldn’t it be great to be able to search the site of your choice – any site – very fast, and very easily, from that URL bar? You’d never need to visit the sites again to search them.

Chrome enables this. The first step is to left-click on the URL so that it is selected, and then right-click on it and select “Edit Search Engines…”:

Chrome - Edit Search Engines

Google Chrome - Edit Search Engines

This brings up a screen like the following, in a new tab:

Chrome Search Engines

Google Chrome - Search Engines (Click to enlarge)

Here you can either customise current search engines, or add new ones using the form at the bottom of the page.
To acquire the correct URL to use, simply run a search on the site in question and examine the resulting URL on the search results page. Copy this and use it when defining the new search engine, substituting %s for the search terms.

Note you can name the search engine fully, but most usefully of all, you can give it a short reference. In the screenshot, amazon.co.uk has been assigned short reference “a”. To search Amazon, then, you would simply click in your URL bar and type the letter “a”, then a space. The shortcode is recognised and the URL bar changes to look like this:

Chrome Short Search

Chrome Short Reference Search

You now simply proceed to type in your search terms. When you hit Enter, Amazon will be searched and the results page at Amazon will be displayed.

Remember, this kind of short reference searching can be defined for any site you like.

Assigning a default search engine

On the Edit Search Engines page, you can set a particular search engine as your default (this is the search engine that will be used if you don’t prefix your search terms with any short reference). For this you will likely want either Google standard, which will display the usual Google results page, or Google “I Feel Lucky”. When this flag is used on a search, Google bypasses the results page and just takes you to the top ranked result. If you searched for yourself, and asked us to do your Search Engine Optimisation, then this could be you!

To make Google use “I Feel Lucky”, the following parameter needs to be added to the standard search string: btnI=3564. So, the string (the text) for this in the Edit Search Engines page would be as follows:

http://www.google.co.uk/search?btnI=3564&q=%s

In conclusion

If you haven’t yet set your custom search engines, go for it! This is one thing that will make your use of the web much faster.

Now running PHP 5.35

For security and stability reasons, we don’t usually run the latest versions of important software releases on our hosting platform. We do however keep a close eye on when releases are made and we have just updated the PHP version on our Linux platform to version 5.35 (this is just one version behind the latest release).

In order to use this version of PHP on your site, simply head for this icon in your Control Panel:

Switch PHP versions

You can use this to toggle between PHP versions 5.35 or 4.4 at any time.

Alternatively, add the following line into an .htaccess file in a directory within your public_html directory, and that’ll turn on PHP 5.3.5 for just that directory (and the directories below it):

SetEnv DEFAULT_PHP_VERSION 53

If you encounter any problems, just raise a ticket and we will be happy to help.

addFrameScript method of MovieClip class

Many animations can now be coded, so do not need frames. This means we do not have to associate “pre-filled” symbols in the Library with MovieClips, but can instead associate them with the Sprite class or with our own custom subclasses which extend that class.

Sometimes, however, we do need to use the timeline, so must export assets extending the MovieClip class. We can still avoid littering code down the timeline, though, by using the undocumented MovieClip method addFrameScript() in the contructor function of our class. This will insert code into the timeline as if it were on the frame, but it keeps everything tidy instead, inside the class file. It’s therefore highly useful (especially for stopping clips on their last frame!).

Example:

// imports
import flash.display.MovieClip;

// constructor
public function MyAnimation extends MovieClip()
{
   addFrameScript(totalFrames-1, finish);
}

// new method
private function finish():void
{
   trace("stopping on last frame!";)
   stop();
}

Note that the frame counting is zero-based (as with arrays): frame 1 is considered by Flash to be frame 0, so we use an offset.

How to use localToGlobal() in ActionScript 3.0

localToGlobal() in AS3 not working? The LiveDocs on this potentially very useful method, along with its partner globalToLocal() are not actually very helpful. What they don’t make clear is that you need to be sure to overwrite your point when using it:

// WRONG:
var pt:Point = new Point(target.x, target.y);
target.parent.localToGlobal(pt);
parent.globalToLocal(pt);

// RIGHT:
var pt:Point = new Point(target.x, target.y);
pt = target.parent.localToGlobal(pt);
pt = parent.globalToLocal(pt);

Simply running a localToGlobal() method on a point in a given scope is not enough. You need to write the result back into the point. You might be forgiven for not seeing this, because it was not necessary for the equivalent method in AS2!

localToGlobal() and globalToLocal() can be the source of considerable frustration, especially as differences such as this are not mentioned by Adobe. But properly understood these methods are not complicated.

Choosing a Flash video format for pseudostreaming

Introduction

StarburstWe’ve been spending a lot of time recently examining the different video codecs available for Flash and conducting various tests. Our objective has been to choose the best quality video format which also enables pseudostreaming – without using custom servers such as Lighttpd.

Pseudostreaming means imitating the behaviour of a RTMP streaming server such as Red5 or Flash Media Server by simply using a PHP script such as xmoov.php. Using such a solution does not enable collaborative behaviour such as the broadcasting of live webcam streams, but it does allow jumping ahead to parts of a video which have not yet downloaded. This is probably the benefit most people seek from a streaming server solution and it is much easier to set up than a streaming server. It is the choice of YouTube and Google Video.

What’s required for pseudostreaming?

Pseudostreaming requires a video format which supports it and a video player which supports it too. Two leading open source video players, JW Player and Flowplayer both support it, because they send a request indicating how much of the video file should be sent back.

Flowplayer requires a plugin SWF. This player is configured using JSON. JSON is not especially complicated but we found this config method fairly verbose. It also uses its own flash embed routine. You have to get the config exactly right for pseudostreaming via xmoov to work with Flowplayer. There are scarce resources on the web. The main one points to this page, which is now outdated, but it can be done, and if you need to know how, ask us.

We find JW Player easier to configure for pseudostreaming with xmoov. The info page is here and after we pointed out a fault with the player, here, the latest release works properly with pseudostreaming.

Comparing video formats

Perhaps we will use JW Player as our player, then, but we’re still no closer to deciding which video format to use.

H.264 & F4V

It seems safe to say that the best quality format for the web at the moment is the H.264 standard. We are seeking to encode video using Adobe Media Encoder, which is included with Creative Suite 4. This program uses the MainConcept H.264 Video codec and using this codec it can encode into either MP4 format or F4V format. At least Flash Player 9.0.115.0 is required to play back this standard.

F4V was created by Adobe in order to address shortcomings in the FLV format. It determines additional file meta data and enables the embedding of H.264 video in this custom format.

At the time of writing, according to our research, you can forget about using H.264 for pseudostreaming unless you have shell access to your Linux server and wish to try compiling a PHP module like this or you are using lighttpd as your web server.

Neither Flowplayer nor JW Player support pseudostreaming of either F4V or MP4 videos using the H.264 standard along with xmoov.php.

Eric Lorenzo Benjamin Jr of xMoovStream also offers his own video player, which looks good, and a separate streaming server solution. This can stream MP4 (H.264) files to Apple’s iPhone and Quicktime, but not to Flash Player. We’re still limited to FLVs with this player.

F4V problems

A little more about F4Vs while we are on the topic: the format currently appears to be faulty – at least when encoded by Adobe Media Encoder CS4:

  • It does not add keyframes at navigation cue point times
  • It does not trigger cue point event listeners in the expected manner
  • It does not respect custom keyframe intervals

Some more reasons not to use this format yet, perhaps, despite Adobe having urged everybody to switch to it. If you wish to have high quality video without xmoov pseudostreaming, use MP4 instead for now. (Under our tests, MP4s embed seekpoints correctly whereas F4Vs do not.)

We’re left only with trusty old FLV as the format we can pseudostream.

Setting up FLVs for pseudostreaming

Choosing a codec

You have a choice of two different codecs when exporting FLVs using Adobe Media Encoder: Sorenson Spark or On2 VP6. The latter is the later, recommended, codec.

Choosing a keyframe interval

Notice the option to “Set Keyframe Distance” in the Export Settings under Video → Advanced Settings. When using pseudostreaming the player can only jump to the closest keyframe. The more keyframes, the more precise your pseudostreaming will be, but the larger your file will be.

The default is a keyframe interval of 30. If you take this down to 10 you will see a lot more precision and about a 17% rise in file size. If you take it down to 1, though, you will see a 1000% rise in file size along with your optimal precision. You will also find that the video player takes a long time reading the meta data of the FLV before it plays it. We are happy with the compromise of a keyframe interval of 10.

So you export the video using whatever quality you like, and this keyframe interval. You stream it into your player using referring to the config links above. You try seeking to a part of the video which has not yet downloaded. The playhead simply jumps back to the beginning of the video. What’s going on?

Inserting meta data

Well, it’s not enough to have the keyframes in the video. What Adobe Media Encoder unfortunately does not do is insert meta data in the FLV indicating where those frames are. This is vital for php pseudostreaming to work. (Adobe: please provide the option for this in the next release of AME.)

Luckily, there is quite a dated freeware tool from Buraks, of the ActionScript Viewer, which still does the job well: FLVMDI. There is even a GUI available so you don’t need to start working on the command line, and another tool enabling you to view the meta data without tracing it out using Flash.

Once you have exported your FLV file with the ideal keyframe interval, you’ll need to run it through FLVMDI to insert the meta data. Be sure to tick the “Include ‘keyframes’ object” option. It performs this task quickly, then, when you use the file with JWPlayer and xmoov, you should find you can move the playhead to any location and the file will “stream” from there.

Conclusion

The conclusions to be drawn at this point, we believe, are as follows:

  • F4V is a no-go area as there are problems with the format.
  • MP4 (H.264) is the optimal format if you do not require pseudostreaming via xmoov.
  • FLV remains the best format to use if you do wish to pseudostream using these players.

Since pseudostreaming is highly desirable, then, and xmoov is a quick and easy solution, we find FLV to be still the best format.

We hope this article helps get you up and running with Flash video including pseudostreaming. If you spot any problems with it do let us know, and if the article proves popular we may expand on it and insert relevant images.