views:

1548

answers:

4

Hi,

I have a flash video file (FLV) stored in the ByteArray object and would like to play this video. Is there any way to achieve it? Maybe using Alchemy?

Thank you!

A: 

I will not ask Why ByteArray? The answer for your question is YES, but final result will work slow - slower when video is bigger and codec complex. You must read frames and put them as BitmapData in to Bitmap and write own player. The best way is to use Alchemy - then it works faster but also slow :) You can also use haXe. Sound in very similar way. The best point to start is adobe labs. At the end - remember that flv is decoded using hardware - your code will use only processor. Now ask yourself if really you need this feature?

Konrad
A: 

i think "why ByteArray" is actually THE question ... how did it get there? :)

there are numerous approaches ... one was given by konrad ... but as he said it will be slow ... in fact, i think it'll be much slower than you can even imagine ... so here another one:

pass the ByteArray to a server and load the flv from there ... there are several options:

  • remote server: load it to a remote server (probably the one distributing your swf) ... still leaving the question why you don't distribute the flv from there in the first place ...
  • local server:
    1. installed: simply install a tiny local app to do exactly that for you, that is, you can push the bytearray there and then retrieve it over a suitable protocoll (HTTP, RTMP) ...
    2. browser-embedded: same as installed, but you can simply create a Java Applet to do that job ... signed java applets are allowed to bind ports (yes, this is an extra click for the user, but it's as comfortable as it can get) which is what you'll have to do and the rest is really the same as with an installed server ...

in both scenarios, you might run into crossdomain policy issues (probably only when sending, since i think you're allowed to load videos across domains), where you need to respond correctly to FlashPlayer's policy file requests (you can find tons of stuff on that) ... you could bypass sending restriction by making a LocalConnection bridge, as this one for C# ...

good luck then ... ;)


edit: ah ok, now i understand ... actually, there was already a very similar question ... i remember a short interview with some adobe guy, just shortly after p2p feature was announced ... adobe is very shy about this ... actually it took me weeks to find the p2p after flash player 10 was officially released (didn't really have time to bother before) ...

actually, i think this is made on purpose ... in the interview, it was made clear, that adobe is not trying to push away video streaming sites ... the two most important probably are youtube and google video ... youtube is one of the main reasons, why flash player became so popular in the first place ... and it's owned by google, as google video ... allowing easy creation of a p2p media platform would piss google off a lot ... you don't need a lot of servers for that ... "just" good software, but that's affordable ... and i think, adobe does not want to piss off google ... some reasons:

  • they are THE search engine
  • they need google to allow indexing flash based sites
  • google is n times bigger
  • google is really trying to get a huge chunk of the RIA market ... they have the GWT, chrome, the V8, the native client ...

so i guess adobe does not have that much of an interest to do so ... it's pretty much a bit, like when google announced their payment system (was it GPay or so?), which was a direct concurrent of PayPal ... eBay is one of google's most important income sources ... and actually i never heard anything about it again ...

many decisions are political, when it comes to big companies ... and i think, the one not to make flash player's p2p too strong is one of them ...


greetz

back2dos

back2dos
Thanks for answering. I was afraid that these were my only options and you just confirmed that (I was hoping that I overlooked some other method). To answer the WHY question :) - I'm working on p2p media streaming using the new functionality available in Flash Player 10 and got to the point where I've got video in ByteArray at clients, but can't display it :) Cheers and thanks again for your answers.
bartekb
A: 

I'm not sure this is possible at all since I have no idea how Flash encodes SWF embedded videos, but maybe you could convert that flv bytearray to a swf with the flv embedded in the timeline and use that bytearray to display it with Loader.loadBytes...

Cay
+1 ... good idea ... but i couldn't find out how videos are embedded within SWF ... i've always had the impression, they are converted somehow, which would require decoding ...
back2dos
That's a nice idea. It has been done for audio (mp3), so might be possible for video...http://www.flexiblefactory.co.uk/flexible/?p=46
bartekb
A: 

the Loader+MovieClip trick is probably the only way to go, see

http://stackoverflow.com/questions/199068/embedding-binary-video-data-in-a-swf-file

for limitiations. the 2 minute limit is fine for rtmfp2p as distributing larger bytearrays is not feasiable anyway.

Assuming the playback metrics (playhead/current frame) are available, smooth transitions should not be a problem - start playing second swf with mute/visible=false until timelines are in synch, then flip video and sound - this works very well well for netstream/play(), not so sure for plain swf just yet.

Another problem is figuring out exactly the way flv data are imported into the swf and how to construct proper swf at runtime, in as3. So far mxmlc/swfmill were unsucessful in directly embedding FLV for me (it's been a while, things might've changed), only plain flash AS3 was capable of creating bytearray-loadable swf with video. Should be possible though.

On a related note - one question is if its all worth the trouble - if one were to build a successful site featuring p2p VOD like this one, Adobe might as well just cut the line (hacking up something like no swf movieclips with embedded video to be loaded from bytearrays...).

I'm still trying to find the cracks to accomplish p2p vod, in case someone would be interested feel free to msg me @ [email protected] | sed -e 's/A/e/'

upalse