Play FLV from ByteArray in Flash Player - apache-flex

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!

There is now a better way of playing a video that you have stored in a ByteArray using NetStream.appendBytes().
Here is an example of it in use: http://www.bytearray.org/?p=1689

The Loader+MovieClip trick is probably the only way to go, see this
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 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...

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?

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:
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) ...
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 ...

Related

Haxe + real-time network

i try to find a good combination of libraries for managing a real-time communication (client/server) using Haxe (only Haxe, not openfl or other framework base on Haxe) targeting flash (swf) for the client and no preference for the server except don't use neko.
The goal is to make a simple tchat and put a display representation of all clients on an aera. Each client can move his representation in this area, and the other sees the movement.
I find some Lib to make this :
https://github.com/soywiz/haxe-ws
https://github.com/MattTuttle/hxnet
haxe-js-kit
But I'm not sure of the best way to adopt.
Do you have any suggestion/remarks/tips to choose the better way ?
Disclaimer: I wrote the library that I am sharing here.
My somewhat new library mphx may be able to help you. It can manage 'rooms' of connections, allows client to server and server to client messaging in the form of events, and best of all, is cross platform. It also works in the web with websockets.
It was originally an extention of HxNet, however I wanted it to be easier to use. Connecting and sending a 'message' with data just takes a few lines.
I have a few examples in the github repository, the simplest being the 'basic' example. One of your requests you have is that it doesn't rely on one of the big libraries (open fl, etc) and mphx doesn't. The basic example proves that, and only runs in terminal. That being said, it can be used with haxeflixel, for that you can see the other examples.
It sounds like your main goal is to have simple, graphic multiplayer. For that you can look at the 'movement' haxeflixel example.
Documentation is still a little skim, and the code is alpha, so it might change or break. That can probably be said for most of the library's you listed though. The best way to install it is like this
haxelib git mphx https://github.com/5Mixer/mphx.git
That will not install the examples though. To run them, either download the repository as a zip, or just git clone it, and go into the examples folder.
Library: https://github.com/5Mixer/mphx
Old video's I made. A little outdated, most likely.
Video 1: https://www.youtube.com/watch?v=07J0wLXwH0g
Video 2: https://www.youtube.com/watch?v=MUx2CUtsnTU

Recording Audio From Web Page

I'm looking for a solution for capturing audio from a user's microphone and posting it (preferably as MP3) to a server. I need something that I can embed in a web page.
I've seen where Flash can do this, but I understand that this approach requires expensive server-side software from Adobe. I'm not aware of whether Silverlight may provide any capabilities to assist with this.
I'm curious what others have done. Any advice would be greatly appreciated.
You can do it with Flash and either Red5 or haXeVideo or the server, both Open Source. Regarding offering a final MP3 to the user, you will need something else because these 2 tools only record to FLV format due to the licenses needed to encode MP3s. You can use something on the server such as FFMPEG for the transformation, but still, read the small print regarding MP3s.
Good luck
Juan
SilverLight 4 now has the ability to record audio. http://blog.ondrejsv.com/post/Audio-recorder-Silverlight-4-sample.aspx shows encoding PCM to WAV
Silverlight does not have this capability, currently (or in their upcoming 3.0 release). Flash would be the way to go.

Convert video format to Flash Video automatically

I need to allow web site users to upload videos to my web site in various common formats. From these I need to convert them to Flash video, and also limit their lengths and size. I need to do this automatically as part of the web site processing.
Is there some simple tool that will allow me to do this? If not, can you point me in a direction that might help me out.
Thanks.
With ffmpeg you can run the following command to convert input.avi to output.flv for flash:
ffmpeg -y -i input.avi -acodec mp3 -f flv output.flv
ffmpeg or mencoder is usually used for this kind of thing.
As you are using asp.net you should really be interfacing with the DLL. There is also a c# wrapper available for ffmpeg.
I use ffmpeg and it works perfectly well doing this with my videos.
I've had this issue recently too, and I didn't want to go down the route of implementing a video conversion backend on the server.
In the end, what seemed like a reasonable compromise would be to make use of a video conversion service supplied by one of the online services - something like bits on the run's API, although it is a paid service, seemed like it would straight forward enough to implement as a web service.
However, if this additional cost is not acceptable, then in a PHP world, I would try to use something like ffmpeg-php. I guess there must be an equivalent in the asp.net world too, but bear in mind that video conversion can potentially take a really long time, and kicking off this process in a web scripting language is not ideal, if you are waiting for the request to finish, or are facing execution timeouts.
I think you need a server side software like Adobe Flash Media Server. It can convert video automatically to flv on your server.

Large file download in background, initiated from the browser

Is there any reasonable method to allow users of a webapp to download large files? I'm looking for something other than the browser's built-in download dialog - the requirements are that the user initiates the download from the browser and then some other application takes over, downloads the file in background and doesn't exit when the browser is closed. It might possibly work over http, ftp or even bittorrent. Platform independence would be a nice thing to have but I'm mostly concerned with Windows.
This might be a suitable use for BitTorrent. It works using a separate program (in most browsers), and will still run after the browser is closed. Not a perfect match, but meets most of your demands.
Maybe BITS is something for you?
Background Intelligent Transfer
Service Purpose
Background Intelligent Transfer
Service (BITS) transfers files
(downloads or uploads) between a
client and server and provides
progress information related to the
transfers. You can also download files
from a peer.
Where Applicable
Use BITS for applications that need
to:
Asynchronously transfer files in the
foreground or background. Preserve
the responsiveness of other network
applications. Automatically resume
file transfers after network
disconnects and computer restarts.
Developer Audience
BITS is designed for C and C++
developers.
Windows only
Try freeDownloadManager. It does integrate with IE and Firefox.
Take a look at this:
http://msdn.microsoft.com/en-us/library/aa753618(VS.85).aspx
It´s only for IE though.
Another way is to write a BandObject for IE, which hooks up on all links and starts your application.
http://www.codeproject.com/KB/shell/dotnetbandobjects.aspx
Depending on how large the files are, pretty much all web-browsers all have built-in download managers.. Just put a link to the file, and the browser will take over when the user clicks.. You could simply recommend people install a download manager before downloading the file, linking to a recommended free client for Windows/Linux/OS X.
Depending on how large the files are, Bittorrent could be an option. You would offer a .torrent file, when people open them in a separate download-client, which is seperate from the browser.
There are drawbacks, mainly depending on your intended audience:
Bittorrent is rarely allowed on corporate or school networks
it can be difficult to use (as it's a new concept to lots of people).. for example, if someone doesn't have a torrent client installed, they get a tiny file they cannot open, which can be confusing
problems with NAT/port-forwarding/firewalls are quite common
You have to use run a torrent tracker, and seed the file
...but, there are also benefits - mainly reduced bandwidth-usage on the server, as people download also seed the file.

What are effective options for embedding video in an ASP.NET web site?

A quick glance at the present-day internet would seem to indicate that Adobe Flash is the obvious choice for embedding video in a web page. Is this accurate, or are they other effective choices? Does the choice of ASP.NET as a platform influence this decision?
Flash is certainly the most ubiquitous and portable solution. 98% of browsers have Flash installed. Other alternatives are Quicktime, Windows Media Player, or even Silverlight (Microsoft's Flash competitor, which can be used to embed several video formats).
I would recommend using Flash (and it's FLV video file format) for embedding your video unless you have very specific requirements as far as video quality or DRM.
Flash is usually the product of choice: Everyone has it, and using the JW FLV Player makes it relatively easy on your side.
As for other Video Formats, there are WMV and QuickTime, but the players are rather "heavy", not everyone might have them and they feel so 1990ish...
Real Player... Don't let me even start ranting about that pile of ...
The only other alternative of Flash that I would personally consider is Silverlight, which allows streaming WMV Videos. I found the production of WMV much better and easier than FLV because all Windows FLV Encoders I tried are not really good and stable, whereas pretty much every tool can natively output WMV. The problem with Silverlight is that no one has that Browser Plugin (yet?). There is also a player from JW.
One consideration would be whether video playback is via progressive download or streaming. If it's progressive download, then I would say use Flash because you get a wider audience reach.
For streaming wmv, it is out of the box functionality provided by Windows Media Services
For streaming flash, you will have to install a streaming server on your Windows box. Some options are:
Adobe Flash Media Server (Commercial)
Wowza Media Server (Free/Commercial)
Red5 Flash Server (Open Source)
If you have access to Microsoft Expression Encoder 2, you can use that to encode a video file and generate a Silverlight video player. Then if you have IIS 7, you can use Adaptive or Smooth Streaming also checkout Smooth HD for a really cool example.
You can also do streaming from the free Microsoft Silverlight Streaming Service. It's connected to a Windows Live account.
A consideration is that the client will need to have Silverlight installed, just like Flash, but Flash has been around longer.
<object width="660" height="525"><param name="movie" value="http://www.youtube.com/v/WAQUskZuXhQ&hl=en&fs=1&color1=0x006699&color2=0x54abd6&border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/WAQUskZuXhQ&hl=en&fs=1&color1=0x006699&color2=0x54abd6&border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="660" height="525"></embed></object>
I have worked for a company that developed a system for distributing media content to dedicated "players". It was web based and used ASP.NET technology and have tried almost every possible media format you can think of and your choice really comes down to asking yourself:
does it needs to play directly out of the box, or can I make sure that the components required to play the videos can be installed beforehand?
If your answer is that it needs to play out of the box then really your only option is flash (I know that it is not installed by default, but most will already have it installed)
If it is not a big issue that extra components are needed then you can go with formats that are supported by windows media player
The reason why windows media player falls into the second option is because for some browsers and some formats extra components must be installed.
We had the luxury that the "players" were provided by us, so we could go for the second option, however even we tried to convert as much as possible back to flash because it handles way better than windows media player
"Does the choice of ASP.NET as a platform influence this decision?"
Probably not.

Resources