Sunday, November 28, 2010

AJAX and File Upload — Do They Go Together

In the purest sense, AJAX does not support file upload. Two main reasons:
  1. Cannot specify form data encoding type (enctype) in AJAX form
  2. The method in the form tag is not really executed

But what is the idea of AJAX? It is retrieving content from the web server without refreshing the web page. In the case of a file upload, the browser sends a file to the server and retrieve some sort of acknowledgement of the upload. So, is it possible to perform a file upload without refreshing the webpage?

Most of the work around solutions on the Internet make use of an iframe. One of the nicer work around solutions found is by webtoolkit. It has both pre and post function calls. So, actions can be done before the upload and after the upload has been completed. The code below is an adaptation of that solution.

One of the most outrageous work around is a hack in Firefox. It involves modifying one of Firefox's internal setting variables (signed.applets.codebase_principal_support). Yeah, Not a good idea as it is browser dependent and potentially breaks down in future versions.



JavaScript for AJAX like File Upload
// JavaScript Document

// Author: Luke Lau

// This JavaScript is based on AJAX iFrame Method written by
// webtoolkit (http://www.webtoolkit.info/ajax-file-upload.html)


function AIMonStartCallback () {
  // do something useful before submit (onStart)

  return true;
} // function AIMonStartCallback



function AIMonCompleteCallback (response) {
  // do something useful after submit (onComplete)
  document.getElementById('imageLibraryAJAXContentContainer').innerHTML = response;

  // unregister event listeners because content has changed on the page
  registerImageLibraryEvents(false);

  // re-register event listeners based on new content on the page
  registerImageLibraryEvents(true);
} // function AIMonCompleteCallback



// class definition
AIM = {
  frame : function (AIMcallback) {
    // 1: start of creating an iframe
    // give the iframe an unique id
    var AIMiframeId = 'AIMiframe' + Math.floor(Math.random() * 99999);

    document.getElementById('AIMiframeContainer').innerHTML = '<iframe 
        style="display: none" width="100%" 
        src="about:blank" id="' + AIMiframeId + '" name="' + AIMiframeId + '" 
        onload="AIM.loaded(\'' + AIMiframeId + '\')"></iframe>';
    // end of creating an iframe

    // 2: start of set up the listener / handler for the newly 
    //    created iframe's oncomplete callback
    var AIMiframe = document.getElementById(AIMiframeId);

    if (AIMcallback && typeof(AIMcallback.onComplete) == 'function') {
      AIMiframe.onComplete = AIMcallback.onComplete;
    }
    // end of set up the listener / handler for the iframe's oncomplete
    // callback return the new iframe's id
    return AIMiframeId;
  }, // frame


  form : function (AIMform, AIMiframeId) {
    // modify the target attribute of the form to the newly created
    // iframe (referenced by id)
    AIMform.setAttribute('target', AIMiframeId);
  }, // form


  submit : function (AIMform, AIMcallback) {
    // 1: set up the form just before it starts
    AIM.form(AIMform, AIM.frame(AIMcallback));

    // 2: start of set up the listener / handler for the newly created
    //    iframe's onstart callback
    if (AIMcallback && typeof(AIMcallback.onStart) == 'function') {
      return AIMcallback.onStart();
    } else {
      return true;
    }
  }, // submit


  loaded : function (AIMiframeId) {
    var AIMiframe = document.getElementById(AIMiframeId);

    if (AIMiframe.contentDocument) {
      var AIMiframeDocument = AIMiframe.contentDocument;
    } else if (AIMiframe.contentWindow) {
      var AIMiframeDocument = AIMiframe.contentWindow.document;
    } else {
      var AIMiframeDocument = window.frames[AIMiframeId].document;
    }

    if (AIMiframeDocument.location.href == 'about:blank') {
      return;
    }

    if (typeof(AIMiframe.onComplete) == 'function') {
      AIMiframe.onComplete(AIMiframeDocument.body.innerHTML);
    }
  } // loaded
} // AIM

Monday, November 22, 2010

Editing Mothership Stories Society's Video Footages

Editing approximately 2 hours of video footages is a long and tedious job (even when Marilyn Norry, the founder of Mothership Stories Society, has provided the segments she would like to use to build the 3 minutes final product. In order to edit the video footages with Apple's Final Cut Express, all footages must be converted to a format it understands and can be played without rendering.

So far, the editing process is as follow:

  1. Convert video footages to Apple Intermediate Codec (use MPEG Streamclip by Squared 5 and Toast by Roxio)
  2. Import all video footages into Final Cut Express
  3. Synchronize footages from multiple video recorders (by use of Markers)
  4. Add Markers to video to mark the start and end of the segments
Below is a screenshot of what has been completed so far.

Saturday, November 13, 2010

Video Shoot at Mothership Stories Society

Arrived at location around 9:20 AM. It is a cloudy day but it is still too bright to have the person siting right next to the open window. Will rely on interior lights and extra lights we have brought along.

Some Changes: The interviewer, Marilyn Norry, the founder of Mothership Stories Society, will not be on video and her voice will not be in the final video. Therefore, only 2 Kodak Zi8 video recorders and 1 Sennheiser wireless microphone are required. Also, the Zoom H2 audio recorder will only be gathering voices of everyone; this is to help in editing.

Setting Up: Revisited all 4 shooting areas and roughly identified where to place the 2 Kodak Zi8 video recorders. It was not possible to pre-setup the equipment we do not know who will be at which area. Though, we did set up 2 Kodak Zi8 video recorders and 1 Senniheiser wireless microphone at one of the areas for testing. We also reconfigured the lights: 1 light to be a white light and the other to be yellow light. Sound check (audio level) will have to done on an individual basis.

Framing and Aspect Ratio: The interviewee is to be framed as close to the centre as possible and only showing the head down to the upper chest. It was decided to shoot in wide-screen (i.e., 16:9) instead of the standard format. This is to allow wider range of possibilities in editing (i.e., cropping, etc.).

Ready Set Go: Reset (reformatted) all memory cards on the Kodak Zi8 video recorders and the Zoom H2 audio recorder.

Quiet on the Set: Everyone there has worked in the film industry. Everyone know about the importance of staying quiet during recording. It doesn't and didn't always happen. Second, third, etc. take doesn't mean the interviewer and or the interviewee messed up.

It's a Wrap: The recordings where completed in about 2 hours. 4 interviews were recorded. 52 minutes of raw video footages in 12 files (approximately 5.2 GB). The converted files (Apple Intermediate Codec format for Final Cut Express to use) are about 71.1 GB.

Lessons Learned:
  • Scouting out the location before the shoot is a must. It helps identifying gear requirements (i.e., electrical extension cords / power strips, lights, etc.) and challenges (i.e., too much light from the outside, too noisy, etc.).
  • Be prepare for uncontrollable noises and interruptions.
  • Kodak Zi8 video recorder's battery drains faster than expected. The battery almost emptied out after 25 minutes of shooting. Good thing we have an AC adapter and second a battery.
  • Make sure there is a clip or body / fashion tape for the lapel microphone.
  • Kodak Zi8's face recognition feature does a fairly good job in keeping track of human faces. Unfortunately some background objects appear to be more focus than the subject in front.
  • Fixing the position for each camera is great but it also create a challenge. Whenever the interviewee shifts position dramatically, he/she is no longer where he/she is supposed to be at and potentially clipped by the edges of the frame.
  • Framing the subject along the edges of the frame or too close too the edges of the frame has the same challenge as fixing the position of a camera. There is no room for movements.
  • Converting raw video footages into Final Cut Express ready format, Apple Intermediate Codec, with Squared 5's Streamclip is time consuming (good thing for batch mode). It took about just as long to do the conversion as the footages themselves. As well, the converted files are about 15 times the size of the original raw video files.

Friday, November 12, 2010

Preparation for Mothership Stories Society Video Shoot

Based on the initial information about the task, the following equipment was selected.
  • 3 Kodak Zi8 video recorders with 2 extra batteries and 2 AC adaptors
  • 1 Zoom H2 audio recorder with 1 set of extra batteries
  • 2 Sennheiser wireless Microphones with 1 set of extra batteries
  • 2 lights with 2 different sets of bulbs (white and yellow)
  • 3 tripods
  • 1 mini-tripod
  • 3 electrical extension cords
Why so much equipment? The main reason is that this is the only opportunity to shoot the interviews; therefore, backup equipment is necessary.

The crew (Helen and I) visited the shooting location, home of Mothership Stories Society’s founder, a day prior to the recording day. With 4 interviewees, 4 locations within the home were identified.

Some of the challenges are too much natural light from outside through the windows, balancing interior lighting, distracting background objects, etc.

Thursday, November 11, 2010

Test Shoot at Rouge Lounge, The Event Space

Arrived at location around 2:00 PM on a rainy fall day. It is not super bright outside but there is enough contrast. Hence, the best way to do the shoot is exposure bracketing. What is exposure bracketing and why it is necessary? Exposure bracketing is shooting the same subject multiple times with different exposure time. Each of the shot will provide a different dynamic range of luminance of lightest and darkest areas of that frame. Through post-processing, a single High Dynamic Range (HDR) photograph will be generated using specialized software.

Aperture: To capture the highest depth of field (everything in focus regardless of distance from the camera), an aperture of f/22.0 was use.

Exposure Used: Exposure bracketing of 5 shots per frame. Each shot was 0.7 stop off the other. The exposure times ranged from 5.0 s to 30 s.

Lens Focal Length: 10 mm of the 10-20 mm lens was used. The real focal length (measured in terms of 35 mm film is actually 15 mm. This is because the Nikon D2x is not a full-frame (35 mm) DSLR camera.

Number of Frames: With the 10 mm lens it was possible to capture the 360° view with 6 frames (includes sufficient overlaps between frames). To capture the ceiling, it might be sufficient with a single frame. The keyword here is “might be.” Let see what happens when the stitching begins.

The Shoot: It took about 3 hours (including setup, chatting with the owner, still photos of the kitchen, and take down) to shoot 3 separate areas (the main area was shot twice) and a total of 171 photographs were taken (including 6 photos of the kitchen).

Lessons Learned from the Shoot
  • Panoramic tripod head needs to be properly sized for the camera. In this particular case, some parallax might exist because the lens was approximately 0.5 cm off the spinning axis of the tripod head (the camera is bigger than the Nodal Ninja 3 can adjust for).
  • Drastic lighting colours within the same space is an issue. In this particular case, part of the shooting area was lit by red florescent lights and the rest was a combination of halogen lights and incandescent lights.
  • Non-reflecting objects / decorations must be placed in front of mirrors. Otherwise, the camera will be visible.
  • People movements must be reduced as much as possible because of exposure bracketing and long exposure time.
  • A measuring tape would have come in handy to determine the centre of the room (at least the middle between 2 of the 4 walls). It will make the 360° view more evenly distributed.
Exposure Bracketed Photos
6.0 s at f/22.0 (-1.33 EV)10.0 s at f/22.0 (-0.67 EV)
15.0 s at f/22.0 (0.00 EV)25.0 s at f/22.0 (+0.67 EV)
30.0 s at f/22.0 (+1.33 EV)
Composite HDR
Composite HDR with Photomatix

Wednesday, November 10, 2010

Preparation for the VR Tour Shoot of Rouge Lounge, The Event Space

Shooting a VR tour is a little like shooting a standard panoramic photograph. Both captures a 360° view. Some of the differences are:
  • VR tour is a continuous view of the 360° view instead of a flat view
  • VR tour may includes a view of the ceiling or sky
  • VR tour could provide multiple viewing locations (centre of the 360° spin)
To properly shoot a panoramic photograph (one that is free of parallax), a panoramic tripod head is required. To shoot cubical or spherical VR, the panoramic tripod head needs to be able to spin the camera upward (toward the ceiling / sky). So, here is the equipment list:
  • Nikon D2x DSLR with remote release control
  • Sigma 10-20 mm lens
  • Nodal Ninja 3 panoramic tripod head
  • Tripod
  • Nikon D200 DSLR as a backup camera
To prepare for a test shoot, I visited the location and try to identify challenges. Here are some of the challenges found:
  • Different colour lights
  • Bright outside light through the front
  • Structural support poles
  • Mirrors

Monday, November 8, 2010

Virtual Tour of Rouge Lounge, The Event Space

This photography project is to take a series of still photographs and stitch them together to create multi-linked cubic virtual tour.

The virtual tour is of a new Vancouver, BC business establishment called "Rouge Lounge, The Event Space." This lounge has a fairly open space floor plan with a very high ceiling and a large front window. It also has a few rooms.

This virtual tour is to provide potential customers a very good idea or feel of the place without physically visit it. The virtual tour is tol be hosted at Rouge Lounge's future website (yet to be designed and developed).

Thursday, November 4, 2010

A Video Production for Mothership Stories Society

This production is a two-part video project. The first part is to record four to six 10-minute interviews. The second part is to edit the sixty minutes of raw footages into a 3-minute video that will be used on a website.

This video project is for a non-profit’s organization called "Mothership Stories Society." Currently a team of Interactive Design students at Capilano University is redesigning their website. The video produced in this project is to showcased in the redesigned website.

The interviews are targeted to take place on the same day. Hence, the same location. The recording will be done by Helen Khorrami (my classmate at Capilano University) and myself (Luke Lau).

Helen and I will each edit the raw footages into our own 3-minute video.

Monday, November 1, 2010

To AJAX or Not To AJAX WHIP Salon & Spa Website

AJAX in its simplest form is technique of loading content to a page without reloading the entire page. So, it is conceivably that the page consists of nothing but placeholder containers (div tags). That is, an AJAX page, contents are dynamically retrieved and asynchronously loaded to the page based on user interaction. So, when the page is viewed with the "view source" functionality of the browser it contains nothing but one or more placeholder containers. Unfortunately, this is what today's search engines see.

Using AJAX on a public website like WHIP Salon & Spa might not be the best choice because the website is important for potential / new customers to learn about the services offer by the business. Hence, it is very important for the website to be search engine friendly.

To ensure webpages have enough content for search engines to index, it is important to have fall back content. That is, the pages should not just contain placeholder containers. They must include enough content for search engines to identify / properly index them. The good news is that some search engine companies are working on technologies to index AJAX pages.

So, for now, AJAX will not be used on WHIP Salon & Spa's public website. It will be used on its administration website.