FW 2.4 preview

FlashyWrappers v2.4 is coming up and here are some more details!

As you might have noticed, the versioning has accelerated a bit from 2.3 straight to 2.4. That’s because we’ve finally got a chance to get back to the general API and it is being simplified & cleared up.  Also some long delayed features have been  added to 2.4, so we felt it deserved that .4 mark.

The biggest news is the new Mac ANE, which comes just after the new Android ANE introduced in the previous release. This ANE is not “alpha” because it’s 90% identical to iOS ANE, which was already tested by our customers. This ANE outputs mp4 videos natively  & uses AVFoundation instead of FFmpeg, so licensing issues are gone for Mac (regarding FFmpeg and mp4’s).

As for the API simplifications, one sign it needed work was the growing number of capture methods. We’ve had captureMC, captureStage3D, iOS_captureFullscreen and recently also android_captureFullscreen. Another issue were some slight differences in how .init should be used, in regards to OpenGL capture on iOS(you had to set width & height to -1, very hacky), which resulted in if‘s to use different init configs depending on the platform. There were other issues with init as well (long param list even if not needed), and the names didn’t really express what the methods were doing as the meaning shifted for some platforms. For example,  encodeIt in the stone ages of FW really encoded all frames into the movie, but that is no longer true.

So here are the upcoming API changes you should prepare for:

  • init was renamed to start
  • in a typical case of fullscreen realtime capturing on any platform, you just call myEncoder.start(), with no arguments. This will automatically get stage dimensions for fullscreen capture.
  • if you need to capture downscaled video (typically in Flash to increase encoding speed), you specify your desired video dimensions similar to what you’ve done before and the captured frames will downscale automatically. You can use a new method myEncoder.setDimensions(w, h), or you could also set dimensions using myEncoder.start(fps, w, h, ….). In the past you had to use width / height and frameScale combo to achieve downscaling.
  • you can set your target fps either with myEncoder.setFps(fps), or inside start as mentioned above. If you don’t specify fps, it is automatically set to equal the fps of your Flash stage. An important new feature is, that in “realtime” mode frames are automatically skipped if needed to keep the video fps and stage fps in sync. For example, if your game is running at 60fps but your video target is 20fps, FlashyWrappers saves roughly every 3rd frame to compensate for the differences using some timer math. This worked only on iOS until now, while in 2.4+ it works on all platforms. So, you wont’t need to concern yourself about fps differences between video and Flash stage anymore.
  • all the XX_captureXX variants are being deprecated (they will still work but a compiler warning displays when using them) in favor of a single capture method. With no arguments, this method tries to capture fullscreen. Otherwise, you can give it DisplayObject or Context3D to capture. Hint: FW will try to accelerate fullscreen capture in realtime mode whenever possible, so use that for maximum speed (on iOS this takes advantage of OpenGL capturing).
  • formalized “realtime / non-realtime” modes – FW introduces a new switch in start called realtime. It’s a concept that FW has been working with all the time anyway(even mentioned in the docs), but until now it was up to the user to understand how to enable some kind of realtime capturing in the best way, usually by turning multithreading on (on some platforms), or by using iOS_captureFullscreen on iOS etc. From now on, this decision proccess is shifted towards FlashyWrappers. You just tell FW whenever you wish to capture in realtime or not and it switches multithreading or does other decisions which favor speed whenever needed. It also turns on/off fps syncing (frame skipping), which might not be desirable in non-realtime (post-processing) mode.
  • encodeIt renamed to finish.
  • all those changes and more which are not mentioned here are trying to make FlashyWrappers even simpler to use and more understandable & readable in the code. This is how exampleCamera FlashyWrappers core source code looks for all platforms in 2.4:


if (platform == 'FLASH') myEncoder.setDimensions(400, 300);
myEncoder.start();
...
myEncoder.capture();
...
myEncoder.finish();

Of course the events & saving video are left out, but it is hopefully clear how much simpler the code now looks. In 2.3, this is your exampleCamera init (now start) platform dependent code:

if (myEncoder.platform == "FLASH" || myEncoder.platform == "ANDROID") {
myEncoder.init(w, h, 20, 1000000, true, true, 44100, 1, 64000, 0.5);
} else {
if (myEncoder.platform == "IOS") {
myEncoder.init(-1, -1, 20, 1000000, true, true, 44100, 1, 64000);
} else {
myEncoder.init(w, h, 20, 1000000, true, true, 44100, 1, 64000);
}
}

 

Of course you’ll still be able to set some of the former parameters, but some of them are gone (like audio, frameScale, multithreading).

Leave a Reply

Your email address will not be published. Required fields are marked *