Personal tools

MediaSupport

From OpenLaszlo

This page describes support in OpenLaszlo 3.x for media: images, video, and audio.

Media can be compiled into an OpenLaszlo application (e.g. using <resource>), or loaded at run time (e.g. using setSource). In the latter case, media can be proxied through the OpenLaszlo Server (runtime/proxied), or loaded directly if the application was compiled as SOLO (runtime/SOLO).

Contents

Images & Audio

OpenLaszlo 3.0 supports the following image and audio media types:

  • SWF
  • JPEG
  • PNG
  • GIF
  • MP3

Compiled, and Runtime/proxied

In the compiled/proxied, compiled/SOLO, and runtime/proxied cases, image data is passed through largely unaltered. Images already encoded as SWF files are passed through as-is to the Flash runtime. In the case of JPEG, PNG, and GIF files, the compressed image data is not modified, but rather embedded within a new SWF resource and marked as Flash5 compatible.

Audio data follows the same code-path and almost the same rules. SWF audio files are passed through as-is. MP3 and XMP3 files are transcoded into SWF audio by reading one frame at a time and writing into a new SWF movie. The new SWF movie is marked as 30fps, and there is a maximum of 16,000 frames.

JGenerator (http://www.flashgap.com) is used for SWF file generation and when compiling a SWF resource into a Laszlo library or application. JGenerator "fully covers and supports all versions of Flash file format (.swf, .swt) up to current version 5." As of this writing there are two open bugs in our JIRA database that might be coming from JGenerator (LPP-776 and LPP-515).

Runtime/SOLO

For runtime/SOLO media loading, OpenLaszlo supports no more or less than what is supported by the underlying runtime. Flash8 introduced loading of GIF, PNG, and Progressive JPG. Earlier versions of Flash only supported loading of SWF and standard JPG files.

Video

Video in Flash

Video in OpenLaszlo is handled by the underlying platform runtime, the Flash player, whose capabilities vary by version. Flash 5 and earlier supported a primitive form of video consisting of sequences of still images accompanied by a sound track. Flash 6 introduced the first real video codec, known as FLV, and improvements to this codec were made in Flash 7. FLV remains the only video codec supported within the Flash player: video assets must be converted to FLV before being played within Flash.

More information about Flash video can be found here:

http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14571

There is also a white paper available here:

http://www.macromedia.com/devnet/mx/flash/articles/flash_flv.pdf

Video in OpenLaszlo

OpenLaszlo supports many of the video capabilities of the underlying runtime

When targeting Flash 5 and later, since Flash 5 video is essentially a SWF movie, it can be used within OpenLaszlo wherever a SWF movie can be embedded or referenced.

When targeting Flash 6 and later, OpenLaszlo shares the limitation of a single video codec, FLV. However, since the OpenLaszlo compiler and server proxy do not understand .FLV files, they must be wrapped as SWF movies before being referenced. For example, "<view resource="test.flv"/>" does not work; the resource must be compiled into a .swf file before being embedded or loaded.

As of release 3.4, OpenLaszlo also supports the RTMP prototocol and has APIs for interacting with video servers such as the Flash Media Server and the Red5 server.

Producing FLV Video

In a commercial workflow video can be transcoded to FLV using the Flash Video Kit or Flash Professional, both commercial products from Macromedia.

In an open-source workflow the principal tool is the FFMPEG library http://ffmpeg.sourceforge.net , which is able to encode in FLV format. There are a variety of utilities built on FFMPEG, including the Riva FLV Encoder, available at http://www.rivavx.com/.

[TBD: how to wrap .FLV into .SWF]

Implementation Notes

Media transcoding within both the compiler and server is implemented by the Java Transcoder class.

(WEB-INF/classes/lps/server/src/org/openlaszlo/media/Transcoder.java)

Actual transcoding of media types is done in JGenerator-2.2 within the Bitmap class.

(WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/api/image/*)

References

http://www.macromedia.com/devnet/flash/articles/video_guide_04.html