Archive for December, 2008

Using FFMpeg to Encode Movies for the iPhone

Tuesday, December 30th, 2008

FFmpeg (http://www.ffmpeg.org/) is a great tool for encoding movies in any format and works nicely for encoding movies for the iPhone. The main issue we ran into was finding the right parameters for FFMpeg. As is the case with most open source projects, the documentation for FFMpeg is sparse. From Apple’s documentation we knew the specifications for encoding were:

  • MP4 file format
  • H.264 Baseline Profile Level 3.0 video, up to 640 x 480 at 30 fps. Note that B frames are not supported in the Baseline profile.
  • MPEG-4 Part 2 video (Simple Profile)

Our own requirements were to produce two encodings, a full size one for the web and a secondary one that was optimized for the iPhone. We tried several different combinations, gathered from various forums and blogs, before we were able to find the right set. The parameters that worked successfully for us are:

/usr/local/bin/ffmpeg -i $INPUT -acodec libfaac -vcodec libx264 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me_method umh -subq 5 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bufsize 2M -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -vb 1500k -ab 128k $OUTPUT_WEB -vcodec libx264 -s 480x320 -ab 64k -vb 480k $OUTPUT_IPHONE

DivX Component for QuickTime not compatible with iPhone Simulator

Tuesday, December 30th, 2008

If you updated your iPhone SDK to 2.2 and find that movies no longer play in the iPhone Simulator, it is probably because of the QuickTime DivX component. With the most recent SDK (2.2) this particular component is incompatible with the iPhone Movie Player. You will likely see a message like:

[code lang="objc"]Error loading /Library/QuickTime/DivX Decoder.component/Contents/MacOS/DivX Decoder:  dlopen(/Library/QuickTime/DivX Decoder.component/Contents/MacOS/DivX Decoder, 262): Symbol not found: _SCDynamicStoreCopyConsoleUser

Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis

Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.sdk/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration[/code]

Unfortunaltely, the only way to fix this is to delete the two offending files: DivXEncoder and DivXDecoder. These files should be in /Library/QuickTime

If you are still having trouble playing movie files, check that the file format is mp4 and conforms to the following specification (from Apple’s documentation for MPMoviePlayerController):

  • H.264 Baseline Profile Level 3.0 video, up to 640 x 480 at 30 fps. Note that B frames are not supported in the Baseline profile
  • MPEG-4 Part 2 video (Simple Profile)

Chaining Spring View Resolvers

Friday, December 12th, 2008

Take this example of chaining view resolvers:

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean id="jsonViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
<property name="location" value="/WEB-INF/views.xml"/>
<property name="order" value="1"/>
</bean>

And this views.xml:

<beans><bean name="jsonView" class="org.springframework.web.servlet.view.json.JsonView"/></beans>

This should evaluate each view through the XmlViewResolver, then default back to the UrlBasedViewResolver if the XmlViewResolver does not find a view.

Now, let’s say we have the following tiles definition:

<definition name="forecastOverviewReport" extends=".mainTemplate" >
 <put-attribute name="pageHeader" value="Forecast Overview"/>
 <put-attribute name="body" value="/WEB-INF/jsp/forecastOverviewReport.jsp"/>
</definition>

Looks pretty good.

Now, what if we, by coincidence, have this bean definition?

<bean id="forecastOverviewReport" class="com.credera.forecasting.reporting.ForecastOverviewReport">
<property name="employeeDAO" ref="employeeDAO"/>
</bean>

Uh oh. The XmlViewResolver will find the bean definition above (even though it’s not in the views.xml which was explicitly specified!), and give you this lovely error:

org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'forecastOverviewReport' must be of type [org.springframework.web.servlet.View], but was actually of type [com.credera.forecasting.reporting.ForecastOverviewReport]

But without the XmlViewResolver, this would have been perfectly fine. So, if you are chaining in an XmlViewResolver, make sure none of your tiles definition names are the same as any bean definition ids.

Custom Sharepoint Theme

Friday, December 12th, 2008

Creating a new SharePoint theme is a fairly straightforward process. You can entirely leverage the existing themes as a foundation on which to begin constructing your own.

To make a new theme, simply follow these steps:

  1. Navigate to the themes folder: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\THEMES. Make your own theme named “EXAMPLE” by copy/pasting any existing theme folder.
  2. Open your new Example theme and rename the INF file to EXAMPLE.INF
  3. Locate SPTHEMES.XML at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033. Add a new Template entry for your EXAMPLE theme, following the existing format. Replace the image thumbnail and preview references with your own images if you have them available.
  4. Perform an IIS reset or an Application Pool Recycle on your server for the new theme to appear on your SharePoint site.

Note: It is important to follow the case-structure of folder and file names for your new theme to be recognized. For example, if you name your theme folder “Example” instead of “EXAMPLE”, your new theme will not show up. Same goes for the INF file.

Tips: Because you must perform an IIS reset or AppPoolRecycle for any theme changes to appear, I generally find it more productive to build a new theme in SharePoint Designer, using the Alternate CSS option, and then packaging the custom theme once it is finished.

The Quickest Way to Get a Robust Java Application Running

Friday, December 12th, 2008

When developing an open source Java based web application there is frequently a great deal of work involved just to get your environment up and running. First of all the tools need to be selected, based on your requirements and preferences. At a minimum a robust website will require a place to store data (likely a database). Next, decisions will need to be made in regards to development frameworks followed by persistence layer, testing, and logging tools.

All of these choices can lead decision makers to software solutions that require fewer configurations. Previously PHP might have been chosen over a java/jsp solution. That trend has started to shift to Ruby on Rails in recent years.

In order to promote Java based web development to clients or for in house projects, the setup and configuration needs to streamlined and automated. Once this can be accomplished it will allow development to start sooner.

A few months ago I stumbled on a great open source project which provides an excellent solution for just these problems. The project named AppFuse, was started by Matt Raible. It follows a convention over configuration philosophy. In order to get a project up and running a few decisions are made (ie: database, framework, persistence layer). This project then relies on a myriad of open source projects that complement each other well. Most of these projects are heavily used in the Java world and some are the de facto standard.

For some insight on setting up a project with AppFuse please visit the Quick Start Guide. Below is a synopsis of how to get started.

  1. Required Downloads
    • Java (obviously)
    • Maven
    • Database (like MySQL)
    • Eclipse, IDEA, or NetBeans
  2. Follow the configuration settings
  3. Install optional tools
  4. Create a project
    • Run a maven command mvn archetype:create (followed by archetype parameters)
  5. Run your application Customize your application (Introduce business logic)

After step 5 above, the website is fully operational with a role based security layer that allows for user management and user self registration. At this point the website is operational quicker than a Ruby on Rails app. The customization still takes longer than Ruby on Rails scaffolding, but the conventions are provided and keep the development time closer.

The tool that speeds up most of the environment setup is Maven. AppFuse has just started utilizing Maven as of the 2.0 release. If you are unfamiliar with this tool it is well worth checking out the Maven Site. I would liken it to Ant on steroids.

The following is a list of technologies utilized in an AppFuse project.

Apache Commons

Junit

JMock

Spring

Struts

Hiberate/iBatis/JPA

Canoo Webtest

Displaytag

OpenSymphony

Jetty

JSF/Struts/SpringMVC…

Annotations

Cargo

Even if there are different tools and projects that you would like to use on your projects, AppFuse provides ideas for a blueprint by which all projects can be developed. Simply by setting up Maven properly and developing a set of convenience classes and tag libraries, projects can be set up quickly with little configuration. This allows most of the development time to be spent on building the business logic, thus increasing developer productivity.

Provisioning Profiles on the iPhone

Wednesday, December 10th, 2008

Setting up XCode correctly with the provisioning profiles turns out to be more difficult that it ought to be. The most confusing aspect is that the configuration settings need to be identical for both the project and the target. To get to the project level settings you would right click on the project and select “Get Info”. Similarly, to get to the target level settings you would right click on the target and select “Get Info”. Three of the crucial steps are:

  1. Set the Base SDK property to the latest
  2. Choose the correct provisioning profile for both the “Code Signing Identity” and the “iPhone OS Device”
  3. Make sure you are updating settings for the configuration you want to use i.e. Debug, Release or Distribution. These options can be chosen from the top left drop down in the settings panel. For example, you would typically have a separate provisioning profile for distribution and you should choose this for the code signing property value
  4. Copy the chosen provisioning profile to the device on which you are attempting to install the application

Some other things to keep in mind are: a value for “Code Signing Resource Rules Path” is no longer required if the base SDK is 2.2! Adding a value for this property for SDK 2.2 results in an error during install.

Finally, there are two steps to correctly set up the provisioning profile on the device

  1. Download the provisioning profile from your iPhone portal to your mac and drop it on to iTunes. It should automatically be copied over to ~/Library/MobileDevices/Provisioning Profiles
  2. Also, copy it to each device on which you want to install the application through the Organizer in XCode

New Google Reader theme is hard on the eyes

Wednesday, December 10th, 2008

In an effort to simplify the UI (and corresponding HTML) for Google Reader, Google has stripped it down a bit.  Much of the rounded corners and shading are gone, and rendering performance is improved.  (More details on the official Google Reader Blog.)

But why is it that typography and colors took a back seat in this redesign?  The purpose of Google Reader is to present reading material, hence readability ought to be paramount.

I was very comfortable with the old theme, which made minimal use of bold typefaces and tended to present the non-focused screen areas in lower contrast text with a light blue background.  In that design, I found it very easy to fix my eyes on the article I was reading.

The new theme is an assault on the eyes, for a couple of simple reasons.  The background, now almost entirely white, is the new canvas for extensive use of black Arial Bold.  Black Arial Bold on a white background is quite stark — It’s as if the text has been “cranked up to 11.”  I am now finding it much harder to concentrate on a single article or to browse articles by title.

It would be trivial for Google to add some user settings that allow for color and font adjustments.  They’ve even implemented full-blown theme support in GMail.

In the absence of a customizable Google Reader, it looks like I will need to resort to a Firefox extension like Stylish or Greasemonkey to produce a more pleasant reading experience.  That means I will be ditching Google Chrome, which had been my browser-of-choice for Google Reader.

Or, if I don’t want to mess around with software changes, I did find a special accessory store that markets devices for reading high-contrast web sites.