Tag: Web
Flash Video Smoothing FLVs with ActionScript 3
by Bruce on Sep.09, 2009, under Software, Web
On more than one occasion, I’ve needed to allow smoothing of video in my Flash projects. Of course, it’s always best to compress video to being the size that you need, but if you want to allow any zoom effects on the video, allow the user to resize it, or maybe create a low-res version for use on the web, you’ll need to enable smoothing on the video. The performance takes a hit, since the computer playing back the content needs to do some math to make the video look good, but if you’re in a controlled environment, or have a reasonable idea of the audience’s install base, then smoothing is a viable option. I’ll mention two methods of playing back video – using the NetStream class, and using the FLVPlayback class. They each require a different method to enable the smoothing.
The NetStream is streaming at its most basic. You create a connection and stream the content. It takes more code to create the netstream (rather than using an FLVPlayback component that’s on the stage already), but it’s a little more clear how to smooth the video, since you just set the smoothing property of whatever your video is true. Here’s how you might stream something with NetStream, with the smoothing part added.
var video:Video = new Video();
var nc:NetConnection = new NetConnection();
var ns:NetStream;
//
//Call the function below
startVideo();
//
//This function adds the video elements
function startVideo(){
//Add the video to the stage
addChild(video);
//
//connect the netStream/netConnection with the video
nc.connect(null);
ns = new NetStream(nc);
ns.client = {onMetaData:ns_onMetaData, NetStatusEvent:ns_onPlayStatus};
video.attachNetStream(ns);
ns.play("YOUR_VIDEO.flv");
//
//Start with video being smoothed
video.smoothing = true;
}
//
function ns_onMetaData(_data:Object){
//put stuff here if you want.
}
//
function ns_onPlayStatus(e:NetStatusEvent){
//put other stuff here if you want.
}
//
//See the difference between video being smoothed and not smoothed by
//pressing "s"
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKey);
function checkKey(e:KeyboardEvent):void{
if (e.keyCode == 83){
video.smoothing = !video.smoothing
}
}
So, that’s if you use NetStream to add your video. If you have an FLVPlayback component on your stage, then you have to first extract the video stream from it, and then you can apply smoothing to that. You can’t just set a property of the FLVPlayback, since none exists for smoothing.
function smoothVideo(){
var myVideo = FLVPlayback_Instance.getVideoPlayer(0);
myVideo.smoothing = true;
}
Turn the smoothing on and off in the example below to see the effects.
You can see very clearly the difference in the details of the ships and in how smooth the text edges look. Performance does take a slight hit, but it's hard to see in this small video if you have a decent machine. Anyway, there are a few other sites out there that mention this, but I was dealing with it the other day, and thought a good before/after video example would be good.
Connecting with museum visitors online.
by Bruce on Mar.31, 2009, under Web
More and more, a request we are getting here at Boston Productions is to create content that visitors can interact with at home, thereby extending the experience they have had at a museum. Often, this comes in the form of emailing some sort of creation that was made during a visit, and can be retrieved at home. At The Hershey Story, users can email both a photo of themselves on the front page of a vintage newspaper, as well as create a Hershey’s bar wrapper and send that home to be printed and wrapped around a 4 oz. bar. For both of these experiences, we created not an email with an image attached to it, but instead a customizable email with information about The Hershey Story, and a link to the web site to retrieve what the visitor created. The content can be clicked on and downloaded, and now the user is at the web site, free to explore information about upcoming events, membership opportunities and the latest news.
This may seem like a small thing, but since The Hershey Story opened, thousands of emails have been sent to folks with many of them following the link and ending up at the web site. It’s not as invasive as putting them on a mailing list, which is impossible for many since they are under the age of 13 and would need consent, but still creates a connection with the web presence of the institution.
Other opportunities with this method include adding links for Facebook or Twitter on the page that the items are retrieved from, which would provide the opportunity to post the images to social networking sites with just a few clicks. The main point is that you don’t just create a standalone email with some information, but instead create the beginning of an online experience for the visitor that can result in a new membership, a buzz among friends from the photo that just appeared on Facebook, and an introduction to the web site of a venue that may hold more than what the visitor expected.