Showing posts with label
Flash Media Interactive Server / Red5.
Show all posts
Showing posts with label
Flash Media Interactive Server / Red5.
Show all posts
Every so often there are problems with video playback from the VOD example player after setting up Flash Media Server. It seems the Flash player security settings do not provide the correct access permissions to enable playback by default. All that is required to correct this is to set the Player securities Settings manager

to allow playback from the host folder. Thats it.

Adobe always manages to excite me with the introduction of new features into the Flash Media Interactive Server. I must confess though that none has excited me in recent times as much as the introduction of the peer to peer protocol RTMFP which has now has public viewing in the Adobe Stratus Cloud server. True RTMP has managed to carry us this far but, the inherent problems of a TPD hub server to distribute content was becoming all too obvious to see. In truth the client to server to client model was just no longer efficient enough to cope with the expectation of a user base that now expects all video to be desktop application quality. True a myriad of deployment techniques and the geo-location of server clusters helped to solve this problem somewhat but, at a price too costly for the average user. Problem now solved with the real Time Messaging Flow Protocol, a UDP protocol that allows Flash Player 10 to communicate client to client. Security is maintained by the server which acts a a mediator to authenticate and exchange data keys between consenting users. The result is startling. A video chat application I built with a camera encoded value of 960 x 720 x 10 streamed with virtually no lag in motion or audio. My test partner was my long time friendand tag team partner Prof Bill Sanders and we talked for at least 90 minutes with no change in quality whatsoever. The screen shot above was at full screen.
Development techniques are however not the same as defacto FMIS development as you have access to only the main classes Stream/NetStream, Application and Client (I may have missed some out). Notably you do not have access to Remote Shared Object interaction (for the moment). This makes for some interesting jiggery-pokery to distribute data to multi-users. In this, I have found the Application.broadcastMsg,NetStream.send methods as well as data binding techniques invaluable. Without a shadow of a doubt other creative ways of routing the data will show up as people get more comfortable. In addition you have the same old echo problems so a headset is still absolutely necessary. You also cannot access the raw data of the streams audio and video (for the time being, I hope). Visit http://labs.adobe.com/wiki/index.php/Stratus for more information. You can procure a Developer key there and start to try out the protocol for yourself
I will put up the code for this video chat application once I've cleaned up the mess I created in developing it as well as a demo application you can try out.
Bugbears is finally live. The application developed for CBBC provides children with a platform to air their views on a number of topics anonymously. They are provided a voice recording studio where they can select a creature to which their recorded voices would provide the voice track. An animated creature is then created and posted to the site. Visitors to the site can play back these 'bugbears' and tag then with 'hugs', 'respect' or 'feel the same'. A few more features on the site provide the visitor with the ability to leave advice or feedback on the various subjects.
This CBBC project has taken half of the year in development and required nay demanded my complete attention over the time. For the most part it as been 1 long 6month week with lots of 48 hour development sessions generously sprinkled with lots of hair pulling and head scratching and very hairy moments. Lots of lessons have been learned during the process from development and project management perspectives. All I can say is that I now know what it must be like to be a shirt in a washing machine in a hot wash. Nonetheless it has been a wonderful experience and seeing the project develop from use-case diagrams to release version has made all the work well worth it. My colleague and co developer Valentyne Derkach has been a boon and a dream to work with and I often wonder what it would have been with out him on board. Valentyne you rock!!
On a personal note this project allowed me to test the efficacy of MagicMVC (an mvc based scaffolding I developed for Magic Lantern Productions) and explore the possibilities offered by a Finite State Engine and the State design pattern. Indeed the Bugbears application is a Finite State engine managing a number of states (views) which are pulled in at the users request. It provided scaleability and robustness to the application and allowed us to deal comfortable with team development and the constant stream of changes to the application spec which inevitably come as the application was being developed. The use of an interface for state change rather than the use of concrete classes provided the flexibility to manage the intricate retrieval and removal of various classes required to make the system work.
Magic MVC provided the scafolding for tthe large views and because it provides a Flash Media Server hook in its model it allowed us manage NetConnections and Nestreams very comfortably. There is still a lot to be learned and as we put the in finishing touches, Val and I muse over how much better the site could have been if we had done things differently, if we had more time, if we planned better. I guess this is a good thing as it shows we are still developing and are searching to improve. We hope to release MagicMVC in the near future, as we have both found it very useful.
Ubuntu and Ubuntu- Studio have the PulseAudio server as the default sound server. The Ubuntu Wiki documentation states
"There may be problems with getting sound from Adobe Flash v. 9 and earlier, Wine and Skype when these applications use the ALSA protocol. The sound is supposed to go through the "pulse" plugin in ALSA, that passes it to PulseAudio, where it get mixed with all other sound, and passed on to a audio interface.
The problems seems to be related to the pulse plugin in ALSA, and the special ways these apps uses ALSA.
Currently there are three patches for "pulse" that probably can solve the problems with Wine combined with ALSA/pulse."
As usual in "itchy finger" mode I could not resist trying out the PulseAudio patch for Flash Player 9+ in the hope that somehow this enhanced sound server would improve the Flash Player sound-scape. I went to Synaptic and installed the libraries to assist Flash Player 9 deploy PulseAudio. Everything seemed to go as sweet as a nut until, I tried to video conference via the myForum2 video conferencing system. I could get no audio from my chat partner irrespective of what we both did to reconfigure sound. Oh she could hear me with no problems at all but I could not hear her at all. I tried out various Flash Media Interactive Server applications I had build with FMS streaming and they worked though, they were all playing back recorded streams. I also tried to chat via Skype and I got errors stating that I had problems with my sound card which, was frankly rubbish. As a last resort I went back to Synaptic and uninstalled the PulseAudio libraries for Flash and yes not I can hear live streams from the Flash Player again. This one is a bit strange though because, I could playback the BBC live news coverage thats is streamed live from Akamai via RTMP - or perhaps its not as live as it should be. I guess that's a discussion for another day. For the moment what is important is the fact that the Flash Player deploys the ALSA algoritthm for sound and the PulseAudio patches for the moment create a new set of problems. My recomendation for the moment 'Do not patch'. The problems I found were in areas I usually work in, who knows what complications you may introduce to your system by patching.
I'm pleased to put up this link to an article of mine on the Adobe Developer Center. If you are interested in creating an audio playlist with Flash Media Interactive Server 3 then this is a resource you can use.
Streaming AAC/MP3 files with Flash Media Server 3. I will be putting an associated article on converting the playlist to a Papervision 3D modeled version
The Red5 streaming server installation on Linux is configured by default as a start-up service. This may be fine when you are running Red5 as a production server but, definitely not adequate for a development machine, where you may be deploying more than one open socket server (as I do). In such an environment you need to be able to start the server of your choice manually - when you need it. The method outlined below will reconfigure your Red5 server for manual boot. The Red5 service discussed runs on Ubuntu 8.04 LTS
First you need to navigate to the init.d folder
cd /etc/init.d
Stop the Red5 service
sudo ./red5 stop
Remove all the default auto-config settings
sudo update-rc.d -f red5 remove
Finish up by specifying the new config settings (stop always)
sudo update-rc.d -f red5 stop 20 2 3 4 5 .
An untried (untried by me) alternative suggested kindly by Mikko Rantalainen is
"As an alternative, one could specify new config in the second step, for
example:
# start with sequence number 80 at run levels 2, 3, 4 and 5
# stop with sequence number 20 at run levels S, 0, 1 and 6
sudo update-rc.d red5 start 80 2 3 4 5 . stop 20 S 0 1 6 .
I'm not sure about the official run levels for latest debian or ubuntu but, historically runlevel 2 is supposed to be without network connection - so red5 should probably run only at run levels 3, 4 and 5. However, at least default install of Ubuntu 6.06 LTS seems to run at runlevel 2 with active network connection."
My thanks to R.G Manuel and Mikko Rantalainen without whom I would still probably be scratching my head on this one.
Every so often an adage becomes part of your experience. The one for the day was "a friend in need is a friend indeed". I was truly a friend in need and I had a friend indeed in a guy who strangely enough I have never met in person but, I can count amongst one of my closest pals. Greg Whitehead (thats his name) and I met while I was developing the myForum2 online office/conferencing system (Flash Media Server application). He is the PHP guru who I collaborated with to build that and a couple of other systems. Well he saved my Linux newbie arse again, a true friend indeed.
All those who read this little treatise on starting, stopping and restarting Red5 in Linux, you owe this bit of information to him. Okay enough of the waffle.
To begin my distro is Linux Mint (Daryna), Greg is an Ubuntu man. I installed Red5 using the GDebi package installer. Then the 1st hurdle appeared, apparently Red5 was installed successfully but, "Where the Deuce was the damned thing?". As a windows user I expect to see Icons or a start-up link somewhere when I install a service, not in this case. The absence of an install Icon was painfully obvious. After some desperate Googling I managed to find out how to get at the demos, so I could test for the presence of Red5 http://localhost:5080/demos/port_tester.swf. Then the major hurdle, how do I stop the Red5 service. A lenghty session of Googling only brought frustration and desperation. After 3 hours I was irritated and fed up.
Enter Greg the Saviour, and here is the way:
First locate the service by typing the following in your Terminal
cd /etc/init.d
Next type
ls
This will show you all your services. If Red5 is there, you're in business.
To stop Red5, type:
sudo ./red5 stop
If you are successfull you will get the following print out
Stopping Red5 flash streaming server: red5.
To start Red5, type:
sudo ./red5 start
Success will yield the following print out
Starting Red5 flash streaming server: red5.
To restart Red5 type:
sudo ./red5 restart
Successfull you get:
Restarting Red5 flash streaming server: red5.
Thats it folks, if you're new to Linux like moi get ready for the next headache. By the by does any one out there know how I can get my web cam to work in Linux Mint? Once more, thanks G :)
One of the great head scratching experiences of using the Red5 server during its evolutionary path has been how to change the deployment path from its default 'localhost' setting. Its quite simple actually - well for a Windows server - go to conf/red5.properties (you can open this in Notepad or Wordpad) and change the rtmp.host to your IP
# RTMP
rtmp.host=83.170.114.15
rtmp.port=1935
You can change all the other setting to suit your requirements there.

The new Flash Player 9 places a lot on emphasis on the security of streamed content audio and video. A previous Papervision hack allowed access to rtpm content by disconnecting "from the stream, doing a .draw() to a bitmapdata, and reconnecting. This procedure enabled streaming video to be played on a 3D plane". This is no longer possible.
However all is not lost. Flash Media Interactive Server 3 has a property of the Client class, "videoSampleAccess". This property allows the Flash Player read the raw uncompressed video data streamed from the server. Using this property you can set permissions for access to video data in designated folders. To use streamed video from FMIS set up the following statement in your server script.
application.onConnect = function(newClient){this.acceptConnection(newClient);//newClient.videoSampleAccess = 'pv3dstrms';
newClient.videoSampleAccess = '/';The newClient.videoSampleAccess property allows the client application access to raw data of the video streamed from a target folder ( 'pv3dstrms' ) or any/all stream folders/ subfolders ('/') . On the client side set up your usual scaffolding to connect to Flash Media Interactive Server, set up your Video object, and your Netstream. Pass them as arguments to the VideoStreamMaterial. Assign the material to the primitive.
_vns = new NetStream(_vnc); _vns.play("sample_c"); _cvidmat= new VideoStreamMaterial( new Video(), _vns); _cube = new Cube( new MaterialsList({all:_cvidmat}), 300, 300, 300, 1, 1, 1, 0, 0):*IMPORTANT: In your Event.ENTER_FRAME listener method put in the
.updateBitmap(). Using the VideoStreamMaterial declared above it will be, _cvidmat.updateBitmap()
** Open the file VideoStreamMaterial.as in the PV3D materials classes folder and comment out the following statement :
"//this.video.attachNetStream ( null );"
Run your application.
Voila, you will be streaming video from FMIS.
*~* This method of FMIS/Papervision Video Streaming was tested with Great White and Effects branches of Papervision 2.0
*** I have not tried this on any other RTMP Socket server, so I cannot guarantee success with Red5, haXeVideo or Wowza but, it works for FMIS 3. I unfortunately cannot give a live preview as I go not have a public FMIS 3 install.

What a week it has been, exciting and frustating in equal parts. I had virtually no internet at work today and it really spoiled what was so far a decent week. It was "one of those days at the office". Its truly amazing how helpless and depressed it can make one feel. Its also scary to think of how dependent I have become on the internet. I really must find some way to decrease that dependence without affecting my output.
On the plus side 2 days ago one of my major passions got an upgrade. Yes, the new Flash Media Interactive Server is finally on general release. A fantastic job by the Adobe FMIS gang. They really put them selves at the knife's edge for this one and its capabilities are truly breathtaking.
- Off the shelf Video On Demand deployment
- Support for H264 encoded videos
- Support for ACC encoded audio
- An expanded and more granular Server scripting API
- No Bandwidth or Concurrent connection caps (just fabulous)
- Flash Lite Streaming
- Optimized Bandwidth management
- Auto Bandwidth management
and thats just off the top of my head..
Do take it for a Spin.
My second passion Papervision3d got an unexpected boost in the release of a 3d Physics API appropriately named WOW Physics engine. A fantastic complement to the PV3D API. It's fabulous, considering the fact that it is soooo very early in its development. Here are a couple of
flaming balls in a WOW bounding box. I'm really jazzed at the possibilities this new API will provide.
Code
I was looking at an article I wrote a while back and was reminded of a feature of Flash Media Interactive Server, I like a great deal, the virtual directory for streams. Its quite an old feature. It allows the developer to create a folder anywhere on the Server machine and set a name value pair as an identifier to this folder. As a result any FMIS ( or any earlier server FCS or FMS) application can access the streams in this folder by prefixing the required stream with this variable name,
e.g aStream,play("VDir:"+ RecStrm),
Till now this feature could only be set my making changes to the "Streams" tag in the VHost.xml configuration document:
VirtualDirectory>
Streams>
radiostreams;c:/mycustomstrms
/Streams >
/VirtualDirectory>
to use this your server code may be:
aStream,play("radiostreams:"+ RecStrm),
FMIS now offers the ability to programatically set up a virtual directory from the server script. The Stream static method Stream.setVirtualPath(id, path).
It is used in the following manner:
Stream.setVirtualPath("JamSession", "C:/Documents and Settings/aYo/My Documents/My Music");
A particularly useful use case is an FMIS radio station, with each music channel set up as a separate instance of the application, or even a separate application altogether. Nonetheless all instances share a single music vault set up as a virtual directory. Were this not the case each channel would have to have its own streams folder which will definitely need to duplicate data, an unnecessary waste of disc space.

Over Christmas I've had the opportunity to play with a few of my favourite API's, Flash Media Interactive Server, Papervision3D 2.0 et al. A lot of my experiments have been done in one class, trying to navigate my way around new tools and concepts. However this is not the way I like to work. The thought has been gnawing at my soul as to how these experiments would work if developed in a structured manner with a design pattern. What sort of problems would I face? Would there be scope issues? Would somethings just not work? To answer these questions, I developed a simple mp3 playlist which streams the songs from Flash Media Interactive Server. I have added to this a visualizer made with Papervision3D. To make it scalable and to allow me test a variety of iterations of my code I have chosen to base the application architecture on the Strategy pattern. Thus each view is a different strategy made of an MXML/AS3 control that implements a View interface. Thus to change the iteration of my display all I need do is implement a new Strategy. I do love patterns. I like the results and more the point it confirms that I can develop with these API's in the manner I prefer to work.
*An interesting point to note was the effect the wmode attribute had on publishing the swf. In some instances wmode will affect the display and performance of the swf. In this case it made all the animation respond only to Mouse actions. Removing the wmode gave me back my intended behaviours. Using these APIs though unfortunately create huge files and can be very CPU intensive so limitations have to be place on what effects can be used and so on. None the less it is gratifying.
Nothing is move disheartening to an interactive developer than videos sputtering and dropping packets. Its just plain embarrassing, especially when you're presenting to management or a client, all you get for your efforts are raised eyebrows, polite coughs, pursed lips and all that.... The problem of stuttering video in RTMP socket servers, viz, Flash Media Server and Red 5 can be solved either on the client or server. This embarrassing problem is usually the result of insufficient data buffering or insufficient bandwidth.
Stream Buffering: In Actionscript 2.0, the NetStream.setBufferingTime(t:Number) should solve the problem, in Actionscript 3.0, the NetStream.bufferTime achieves the same. I found this approach especially useful when dealing with the problem of stuttering streams from a Red5 server set up.
Rupert Bear was stream optimized on Red5.
AS2_nc:NetConnection = new NetConnection();_nc.connect("rtmp://aYo1/streamingHeadache");_ns:NetStream = new NetStream(_nc);_ns.setBufferTime(5);_ns.play("video1");
AS3
_nc:NetConnection = new NetConnection();_nc.connect("rtmp://aYo1/streamingHeadache");_ns:NetStream = new NetStream(_nc);_ns.bufferTime = 5;_ns.play("video1");