Wednesday, January 27, 2010

How to retrieve XMP Data/Cuepoints using the FLVPlayback

Some users may wonder how they can retrieve the XMP data using the FLVplayback Component.

The best approach is based on the following article

http://www.adobe.com/devnet/flash/articles/flvplayback_fplayer9u3_04.html

and consist of implementing your own Custom callbacks via a custom client class


The FLVPlayback component automatically creates an instance of the class fl.video.VideoPlayerClient, assigns it to the NetStream's client property, and handles all callback messages that come through the NetStream. The default class fl.video.VideoPlayerClient handles only the callbacks onMetaData() and onCuePoint(). Both of these messages generate events (MetadataEvent.METADATE_RECEIVED and MetadataEvent.CUE_POINT) so that you do not need to register a custom class to handle these callbacks.

However, if you do wish to use custom callbacks, you must register a custom client class. You should extend fl.video.VideoPlayerClient to ensure that the onMetaData() and onCuePoint() handling supplied by VideoPlayer and FLVPlayback will continue to work properly.

The requirements for a custom client implementation are as follows:

* The constructor method must take an fl.video.VideoPlayer instance as its only parameter.
* The custom class must include a ready property which should be set to true when all messages expected at the very beginning of the NetStream have been received. This step is necessary because the VideoPlayer class initially hides the video and plays the beginning of the file to access the correct dimensions and duration of the video. It then quickly rewinds the video to the beginning and unhides it. If the rewind occurs before all messages at the very beginning of the file are received by VideoPlayer, there's a chance those messages may never be received.
* It is highly recommended that you declare the custom class as dynamic to avoid encountering runtime errors. Errors may appear if any callbacks are triggered that the class is not set up to handle.
* It is also recommended to extend fl.video.VideoPlayerClient to ensure proper onMetaData() and onCuePoint() handling.

1) Create a new extented Metadata EVENT

Copy IVPEvent.as from the source code of FLVplayback locally under your FLA project under fl\video sub folder

Use the code below to register a new extended event save it in a file ExtendedMetadataEvent.as


package fl.video {

import flash.events.Event;

/**
* Flash® Player dispatches a ExtentedMetadataEvent object when the user
* requests the FLV/F4V/H264 file's metadata information packet (NetStream.onXMPData)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public class ExtendedMetadataEvent extends fl.video.MetadataEvent {


/**
* Defines the value of the
* type property of a xmpDataReceived event object.
*
* @see FLVPlayback#event:xmpDataReceived xmpDataReceived event
* @eventType xmpDataReceived
* @langversion 3.0
* @playerversion Flash 10.0.0.0
*/
public static const XMPDATA_RECEIVED:String = "xmpDataReceived";


/**
* Creates an Event object that contains information about metadata events.
* Event objects are passed as parameters to event listeners.
*
* @param type The type of the event. Event listeners can access this information
* through the inherited type property. Possible values are MetadataEvent.XMPDATA_RECEIVED.
*
* @param bubbles Determines whether the Event object participates in the bubbling
* stage of the event flow. Event listeners can access this information through the
* inherited bubbles property.
*
* @param cancelable Determines whether the Event object can be canceled. Event listeners can
* access this information through the inherited cancelable property.
*
* @param info Determines the dynamic properties to add.
*
* @param vp Determines the index of the VideoPlayer object.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*
*/
public function ExtendedMetadataEvent( type:String, bubbles:Boolean=false, cancelable:Boolean=false,
info:Object=null, vp:uint=0) {
super(type, bubbles, cancelable);
super.info = info;
super.vp = vp;
}


/**
* @private
*/
override public function clone():Event
{
return new ExtendedMetadataEvent(type, bubbles, cancelable, info, vp);
}

} // class ExtendedMetadataEvent

} // package fl.video



2) Use the code below to register the custom client class:


package {

import fl.video.VideoPlayer;
import fl.video.VideoPlayerClient;
import fl.video.ExtendedMetadataEvent;

import flash.events.Event;
import flash.events.EventDispatcher;

import flash.display.Loader;
import flash.display.DisplayObjectContainer;
import flash.utils.ByteArray;


/**
* NetstreamDataVideoClient subclasses VideoPlayerClient, the default
* VideoPlayer.netStreamClientClass value. This way all
* the metadata and cue point handling built in the
* VideoPlayer works properly.
*
* The class is declared dynamic so if any other
* messages are received that we do not support in
* this class (onTextData(), other custom
* messages) no runtime errors will occur.
*/

dynamic public class NetstreamDataVideoClient extends VideoPlayerClient
{

/**
* This variable is set in onImageData and is used to help
* determine when the ready property should be true.
*/

protected var gotXMPData:Boolean;
protected var gotImageData:Boolean;
public var XMPString:String = "";
protected var verbose:Boolean = false;

/**
* The constructor must take a VideoPlayer as its
* only parameter. It needs to pass that argument
* along to the super constructor.
*/

public function NetstreamDataVideoClient(vp:VideoPlayer) {
super(vp);
gotImageData = false;
gotXMPData = false;
}

/**
* Handling for onImageData() message
* Loads the image bytes into a flash.display.Loader
* and adds the image to the
*/

public function onImageData(info:Object):void {
// Only handle onImageData() once. Any time we seek to the
// start of the file, the message will call this function
// again
trace("onImageData");
if (gotImageData)
return;
var loader:Loader = new Loader();
loader.loadBytes(info.data);
var parent:DisplayObjectContainer = _owner.root as DisplayObjectContainer;
if (parent) {
parent.addChildAt(loader, 0);
}
gotImageData = true;
}

public function onTextData(info:Object):void {
trace(info);
recurseTrace(info, "");
}


// FOR LOCAL FILE OR HTTP
public function onXMPData(info:Object):void {
if (gotXMPData)
return;

if (verbose)
trace("NetstreamDataVideoClient onXMPData");

// F4V/H264 uses data to pass raw XMP
if (info.data!= undefined)
{
if (verbose)
trace(info.data);
}
else
{
if (info.liveXML!= undefined)
{
// FLV uses liveXML to pass raw XMP
if (verbose)
trace(info.liveXML);
}
}

gotXMPData = true;

// for (var i in info)
// {
// trace(i + " is " + info[i]);
// }
// trace("####\n");

// XMP came from Adobe Media Encoder for Flash
if (info.data!= undefined)
{
XMPString = info.data;

_owner.dispatchEvent(new ExtendedMetadataEvent(ExtendedMetadataEvent.XMPDATA_RECEIVED, false, false, info));
}
else
{
if (info.liveXML!= undefined)
{
XMPString = info.liveXML;

_owner.dispatchEvent(new ExtendedMetadataEvent(ExtendedMetadataEvent.XMPDATA_RECEIVED, false, false, info));
}
}
}


private function recurseTrace(info:Object, indent:String):void
{
for (var i:* in info) {
if (typeof info[i] == "object") {
trace(indent + i + ":");
recurseTrace(info[i], indent + " ");
} else {
trace(indent + i + " : " + info[i]);
}
}
}

/**
* property that specifies whether early messages have been
* received so it is OK for the player to rewind back to the
* beginning. If we allow the VideoPlayer to rewind before
* all messages at the very beginning of the file are received,
* we may never receive them.
*
* The default class, VideoPlayerClient, only requires
* onMetaData() to be received before rewinding. onImageData()
* also appears at the beginning of the file, so we might miss
* that if we do not override this property and include a check
* for this data.
*/

override public function get ready():Boolean {
return (super.ready && gotImageData);
}

}
}


IMPORTANT: Don't try to parse the XMP data in the callback as it might be causing some timing issue and you want to give the hand back to the Netstream Object ASAP. Instead fire an event back to your client event listener and make sure you will interpret the data when the video will be in a READY to seek state.


3) Receive XMP Data using FLVPlayback

import NetstreamDataVideoClient;
import fl.video.ExtendedMetadataEvent;
import flash.events.*;
import fl.video.*;

VideoPlayer.netStreamClientClass = NetstreamDataVideoClient;

_playback = new FLVPlayback();
_playback.width = 1280;
_playback.height = 720;
_playback.autoRewind = false;
_playback.bufferingBarHidesAndDisablesOthers = true;
_playback.visible = true;
addChild(_playback);
_playback.addEventListener(MetadataEvent.METADATA_RECEIVED, metadataListener);
// the XMP one
_playback.addEventListener(ExtendedMetadataEvent.XMPDATA_RECEIVED,xmpListener);



private function xmpListener(inEvt:fl.video.ExtendedMetadataEvent):void {
var XMPString:String = "";
if (this.verbose)
trace("--- xmpListener ----");
if (this.verbose) {
if (inEvt.info.data!= undefined)
{
XMPString = inEvt.info.data;

trace("RECEIVED XMP DATA = " + XMPString);
// ready to parse
}
else
{
if (inEvt.info.liveXML!= undefined)
{
XMPString = inEvt.info.liveXML;

trace("RECEIVED XMP DATA = " + XMPString);
// ready to parse
}
}
}
}


Hope you enjoy this article !
Time to interpret the data now

http://younsi.blogspot.com/2008/12/interactive-video-in-flash-using-f4v.html

and store some useful XMP Data

http://www.actimus.com/

Free AS3 Interactive Video FLVPlayback component for FLASH CS5

http://shop.actimus.com/product_info.php?products_id=122

Tuesday, January 19, 2010

Urgence Haïti. Internet is finally up

Bill (woody) is an independant internet guru who is highly respected.

On Jan 18, 2010, at 3:46 PM, @…edu.ht wrote:
| > The Teleco Building where ns1.nic.ht and ns2.nic.ht are (were) is completely dust.
| > Thanks a lot for your time to keep .ht up and running well.
|
| Believe me, that's the least we could do.
| And please know that you have our deepest sympathy.
|
| In case you have time to look it over, here are the other things we've been focusing our effort on.
| I'd appreciate a sanity-check, and any help you might be able to give us in prioritizing,
| or letting us know when you know that someone else is already covering something:
|
| - Arranging US military deliveries of diesel to Reynold for the two generators at Boutilliers Hill.
|
| - Coordinating Columbus, Tyco, the Marine Research labs at the University of Puerto Rico, and the US Navy,
| to try to get a festoon cable run from Santo Domingo to Port au Prince, and/or an extension
| from the Columbus branching unit that lies between Port au Prince and Guantanamo.
| We're making sure that people understand that if this comes to fruition, ownership of anything
| that's been aid-funded needs to be divided among Haitian ISPs, not monopolized within Columbus.
|
| - Arranging delivery of SIP VoIP phones (again to Reynold) for the use of the ISPs, emergency responders,
| and Haitian government. Questions here: Are stand-alone phones preferred, or FXS ports on routers,
| with analog phones? How many? Is the local Haitian ISP community prepared to support them with
| an Asterisk or equivalent back-end? Is there anyone there who's prepared to configure each of
| a batch of stand-alone phones?
|
| - Helping coordinate international law enforcement and the technical community to shut down and prosecute
| con-artists who are setting up fake relief donation web sites and spamming to promote them.
|
| What else can we do to help you?
| -Bill


I'm sure other people involved in the relief work can suggest other things, but a few comments from my point of view:

- Communications capability underpins the ability of other relief workers to do their jobs effectively, so although we, as a community, aren't feeding people or tending to their medical needs, we are helping those who are doing those crucial jobs by allowing them to focus on their work.

- In the short-term, the equipment that's been requested by people on the ground has either already been delivered, is onboard a ship that left Jacksonville about twelve hours ago, or is being containerized to load on a ship that's leaving from Port Everglades tomorrow.

- Also in the short-term, keep an eye out for con-artists who are trying to lure people in to fake aid-donation web sites with spam. Law enforcement is coordinating internationally to take those offline as promptly as possible.

- In the mid-term, what our community needs to do is to make sure that backhaul infrastructure gets into place to move traffic in the 1Gbps-10Gbps range from Port au Prince to Miami. There are several cable systems which land in Santo Domingo, and Columbus has a branching unit off Guantanamo, so our main efforts have been focused on getting a festoon cable run around from the Santo Domingo landing (the University of Puerto Rico Marine Research labs have committed their cable-laying ship, crew, and divers, but we're still looking for an appropriate spool of armored singlemode in the 12-24 core range (more certainly wouldn't hurt, as this would be unrepeatered), and on finding funding to get Columbus to run the spur in from their BU. BTC apparently has fiber already existing or in process of turn-up between Port au Prince and the Bahamas, but nobody's been able to get a response from them yet about its status.

- More generally, as a community, we do good when we make sure that places like this, places that may not have large or lucrative markets, are still served by diverse fiber, rather than by a single fragile monopoly, or not at all, as in Haiti's case. There are many countries as vulnerable as Haiti, and many of them have no fiber. Most humanitarian disasters happen in poor countries and these are generally the countries our community currently has the least capacity to serve. We can think a little more broadly than that, looking to a future when people in poor countries have more smartphones, and students and small businesses are getting online. We don't need to wait for markets to develop... we can invest in those markets, and _cause_ them to develop. Then they won't be as vulnerable to disasters like this.

- Thinking to the longer term... The majority of people who die in humanitarian disasters die of second-order effects like starvation and disease that come in the wake of an earthquake or flood or whatever. That's just beginning now in Haiti, and will continue for some time. The people who died in the earthquake itself will be far outnumbered by those who will die as a result of insufficiently prepared emergency response. PCH and Cisco have been trying for _years_ to get donors to support a ready-to-go emergency communications team for disaster response, but it's been impossible to get donors to fund _preparedness_ rather than after-the-fact response. But immediately after an emergency is the _most expensive_ time to acquire generators and fuel and solar panels and wind generators and batteries and satphones and fiber and space-segments and so forth. All of that can be _much more cheaply_ purchased or contracted for beforehand, and delivered on-site weeks earlier. A!
and those weeks are the weeks of effective response that reduce second-order deaths in the wake of an emergency. People who think they're being helpful with a donation now should understand that the donation would have saved ten times as many lives if it had been made a year ago, than if it's made now. If your companies have charitable foundations, please get them to think about that.

-Bill

Monday, January 18, 2010

avatar vs roger dean

Did Prog Rock's Greatest Artist Inspire Avatar? All Signs Point To Yes

James Cameron spent years creating Avatar's floating islands and crazy dragons, and then an army of concept artists brought them to life. But maybe they had some inspiration from somewhere else? Like classic album-cover artist Roger Dean? Behold the evidence.

Chances are, if you've looked at a weirdshistic record cover by Yes, Asia or other bands, you've admired Roger Dean's paintings of surreal landscapes. If you've ever seen all good people turn their heads each day, then you're already a Dean fan.

Connor Freff Cochran, founder of Conlan Press (which is busy putting out a bunch of Peter S. Beagle books, hosting Beagle's 52/50 poetry subscription service, and putting out art books) contacted us and suggested that Avatar's lush moon might have gained some inspiration from Dean. And when you look at Dean's artwork and compare it to the concept art we posted the other day, it's hard not to see the resemblance.

All of this makes me want to rent Avatar (when it's released on DVD) and see if I can sync it up with YesSongs.

Original Post

http://io9.com/5426120/did-prog-rocks-greatest-artist-inspire-avatar-all-signs-point-to-yes/

Other post

http://blog.signalnoise.com/2010/01/06/avatar-vs-roger-dean/
http://www.yannicklejeune.com/2010/01/avatar-roger-dean.html