## QMedia v1.5 | ## Using QMedia

Home | Playback | Internet delivery | Grabbing

## Preparing for Internet delivery

QuickTime's browser plug-in adds extensive multimedia capabilities to browser windows by allowing QuickTime movies to be delivered over the web.

As you may have noticed while surfing the net, some QT movies start playing before the movie is entirely downloaded, as opposed to others that require that the entire movie file be downloaded before they can start playback. This feature, called http streaming, is particularly necessary on the web given that movie files typically weigh several megabytes.

| This kind of streaming is http streaming and does not require any special software on the server side; any http server can do the job. There are other kinds of streaming, like the one involved in live webcasting, that require the presence of a streaming server software, like Entera or Apple's Darwin.

With QMedia you can create and edit movie files that may end up being delivered over the web, e.g. through 4D’s Internet-related features, a custom ITK-based http server, etc. In such cases, you will want your movies to be ready for http streaming so your application has to prepare them accordingly.

Streaming-capable movies fulfill a couple of prerequisites: their data must be in a single fork, they must be self-contained and they must be fast-start.

- Single-fork: Single fork movies store their movie resource (movie atom) in the data fork, rather than in the resource fork of the movie file. This is a requirement for cross-platform movies.
- Self-contained: a QuickTime movie may refer to media in other files. A movie that does not depend on other files is self-contained.
- Fast-start: Fast start movies have their movie atom stored at the beginning of the data fork. This allows the browser plug-in to start the movie as soon as it receives the movie atom, and play the movie while downloading media data at the same time.

These requirements are achieved with a process called flattening. When QuickTime flattens a movie, it creates a single-fork, self-contained, fast-start copy. The media data in the flattened movie may be interleaved (good for playback) and the movie atom may be compressed (faster startup on the web).

Information and utilities for web preparation of movies can be found at the QuickTime website at Apple. The QuickTime Player Pro application also allows you to do this. With QMedia, flattening is done in 4D with the following code:

`` `C_LONGINT``($error) C_LONGINT``($movieRef;$flag) C_TEXT($movieFile;$targetFile)` `$movieFile:= "" ` Let user choose source movie file $targetFile:= "" ` Display "Save as" dialog` `$flags:= 0 `No options` `$error:= QM_NewMovieFromFile($movieRef;$movieFile)` `If``($error = 0)` `$error:= QM_FlattenMovie($movieRef;$targetFile;$flags) $error:= QM_FreeMovie($movieRef)` `End if` ``