Hi All,
I would dearly appreciaty any light anyone could shed on this issue - I have run into a couple of Flash bugs that have stumped me for quite a while, and my deadline is aproaching fast.
Essentially, I would like to play back 3 reasonably high res videos (On2 VP6-S) simultaneously in one Flash App (using flash.video, netstream and netconnect - code only). Unfortunately, when I do this, the video playback drops a lot of frames, however, CPU usage does not go much above 50% - spread over both cores. I’m using a Core2Duo. If I play the same 3 videos simultaneously in 3 separate flash apps (FP10), they play much better (and use close to 100% CPU). I even tried creating it as an AIR app with 3 separate windows (NativeWindow), but that made little difference. I have lodged this as a bug via the Flash Bug Reporting System (http://bugs.adobe.com/jira/browse/FP-2341).
And yes, I do need to be doing something as crazy as this - it is for a pretty cool kiosk app, so I know what hardware will be used (and it has a good Graphics Card).
One promising workaround appeared to be playing back a single NetStream in multiple Video instances, as it is NetStream that does the decoding, so I could decode once and present it in 3 places. Two of my video objects are actually the same flv (on different monitors), so there would be a 33% saving right there. If necessary, I could encode both flvs into a single 1920x1200 flv (I’ve checked - it would play back ok) and then use video.mask to show the relevant bits.
However, another bug has been reported at http://bugs.adobe.com/jira/browse/FP-920 saying this does not work - Video in the object that last called attachNetStream(ns) will play, all others will freeze. They do mention a workaround that gets both videos to play - reset the size of freezed videos on ENTER_FRAME event. However, I cannot get this workaround to work - my first video is empty (not even frozen).
So there are a couple of things I would love any feedback on. Firstly, if anyone has insights on how I could get this to work. Secondly, if anyone could try the “multiple videos on one netStream with workaround” code below (simply copy, paste and point to a relevant flv) and let me know if it works and the versions of software they used, I’d be very thankful.
The Code:
import flash.events.Event;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
showRedrawRegions(true); // both the placeholders and the entire window redraws every frame.
// When only video1 is attached, only video1's region is redrawing
// When both videos are attached, both video's regions are redrawing, BUT video1 is empty.
trace ("Capabilities.version = " + Capabilities.version); // = WIN 10,0,22,91 // in Flash CS4 10.0.2
//var nc:NetConnection = new NetConnection( null ); // Got Eror: 1137: Incorrect number of arguments. Expected no more than 0.
var nc:NetConnection = new NetConnection();
nc.connect(null);
// Connect nc here ...? Unnecessary in this case?
var ns:NetStream = new NetStream(nc);
ns.client = new Object(); // Simplest way to deal with cuePoints and metaData by doing nothing. For more, see http://blogs.adobe.com/pdehaan/2006/07/playing_back_flvs_with_actions_1.html
var stream:String = "test.flv";
var video1:Video = new Video(); // Defaults to size of 320x240
var video2:Video = new Video(); // Defaults to size of 320x240
video2.x = 320;
addChild(video1);
addChild(video2);
ns.play(stream);
video1.attachNetStream(ns);
video2.attachNetStream(ns);
// PROBLEM: Video in the object that last called attachNetStream(ns) will play, all others will freeze.
// See WORKAROUND below for solution:
//WORKAROUND to stop the first split stream from freezing:
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event){
video1.width = 320;
video1.height = 240;
trace ("video1.videoWidth = " + video1.videoWidth);
trace ("video2.videoWidth = " + video2.videoWidth);
// When only video1 is attached, video1.videoWidth = 1920, video2.videoWidth = 0
// When both videos are attached, video1.videoWidth = 0, video2.videoWidth = 1920
}
Letting me know what exact versions of the following software was used would help a lot:
[LIST]
[]Windows/OS (e.g. XP SP3).
[]App code was written in. (e.g. Flash CS4 IDE 10.0.2, Flash Develop 3.0.1).
[]App code was compiled in. (e.g. Flash CS4 IDE 10.0.2, Flex SDK 3.4.0.6955).
[]Type and Version of Flash Player used (e.g. Standalone Debug Flash Player v10,0,22,91).
[/LIST]
The versions I used are listed above.
Lastly, for what it is work, I found three interesting/informative results, but they didn’t help me:
[LIST]
[]When only video1 is attached, video1.videoWidth = 1920, video2.videoWidth = 0
When both videos are attached, video1.videoWidth = 0, video2.videoWidth = 1920
[]When only video1 is attached, only video1’s region is redrawing
When both videos are attached, both video’s regions are redrawing, BUT video1 is empty.
[*]var nc:NetConnection = new NetConnection( null ); // Got Eror: 1137: Incorrect number of arguments. Expected no more than 0.
So I had to change it to:
var nc:NetConnection = new NetConnection();
nc.connect(null);
Does this mean my NetConnection class is different and maybe incompatible with this workaround?
[/LIST]
Many, many thanks.