Tag Archives: walkthrough

Flash live streaming how to

1 Jun

This how to covers how to stream live video or either red 5, FCS, or FMS. I am only covering the basic’s not server side as, or java.

Streaming video is pretty simple once you have a server. I recommend using both red5 and FMS developer version on your local dev machine. This way you can test on red5 without the 10 connection limit, and then test on FMS to insure that your app is working correctly on that platform if your production environment uses it.


First things first

First things first : Make a movie.
Go to the library and add a new video symbol. Drag this symbol onto the stage and name it bCastPreview
.
Now we’ll get down to the basics:

The first thing we should do is define our server url in a variable

broadCastURL=”rtmp://localhost/test”;

whats with that funky url?
if you’ve never used a flash server before your probably like wtf? Flash used a different protocol for streaming, I don’t know the full spec of it (sorry uber’s), so instead of attempting to breakdown something don’t know, let me just say use google. Just know it is the protocol used by flash and flash servers to transfer data.
At the end our url you’ll notice /test change test to whatever you’ve named you application on the server to.

Little bit of back tracking

To add an application in FMS add a directory to the applications folder in the FMS root on your machine. To add an application in red 5 add a new directory in the webapps folder in the red5 root. For more details : use google.

Ok are we ready?

Alrightly we’ve now briefly covered adding your application in FMS and Red5, urls, and protocols, and we have a movie with one variable and a video object. I think we’re ready.

// create a basic netConnection object
var nc:NetConnection = new NetConnection();

// connect to the your FMS or Red5 server
nc.connect(broadCastURL);
// create a netStream object and pass it the netConnection object
//netStream needs this as it is the connection to your server
var ns:NetStream = new NetStream(nc);

what we’ve just done is connect to our flash server and created a new stream object. Why? Well netConnection is just that a connection. So we pass our connection to netStream which is used to play or publish streams. So we now have a stream connection to our flash server. (now that’s breaking it down barney style)

Umm still no video

We have yet to actually connect any video so lets quickly run through setting up or web cam and mic, and get the broadcast going

// setup cam
cam = Camera.get();
// setting dimensions and framerate
//I like to broadcast at resolutions higher than the view will be
//I find this delivers better quality video
cam.setMode(600, 400);
// set up quality
cam.setQuality(25600, 0);
// setup mic
mic = Microphone.get();
mic.setRate(11);

what we’ve just done is setup both our camera and mic.

cam = Camera.get() and mic = Microphone.get() explain themselves.

We are broadcasting or camera at 600 x 400 resolution, although our actually video window will only be 320×240. This is so we can have better resolution in the viewer. This was done with cam.setMode(600, 400);

We’ve also told flash to use up to 25600 bytes of bandwidth to broadcast while maintaining the highest quality we could with cam.setQuality(25600, 0);

And finally we set the rate of our audio from the mic : mic.setRate(11);

Now we’ll attach both sound and audio to our stream object. Then we attach our camera to our video object so that we can see what we’re broadcasting

ns.attachVideo(cam);
ns.attachAudio(mic);
bCastPreview .attachVideo(cam);

and finally what we’ve all been waiting for

ns.publish(“myBroadCast”, “live”);

when publishing you need to give your broadcast a name ie “myBroadCast”, and tell the flash server that this is a live broadcast and we only want to stream it : “live”. Why do we need to tell the server we only want to do a live broadcast? Because based on the string passed the server can do other things, but google will tell you all about that. Like I said – this is the basics.

So we now have a live broadcaster. What next?

Our next step is to make our viewer, because theres no point in having a broadcast if no one sees it ( not that theres anything wrong with that if your into that ).

First step make a movie, make the video symbol, drag it onto the stage and name it : bCastView

//server url
broadCastURL=”rtmp://localhost/test”;
// create a basic netConnection object
var nc:NetConnection = new NetConnection();

// connect to the your FMS or Red5 server
nc.connect(broadCastURL);
// create a netStream object and pass it the netConnection object
//netStream needs this as it is the connection to your server
var ns:NetStream = new NetStream(nc);
//set stream buffer
ns.setBufferTime(2);
bCastView.attachVideo(ns);
ns.play(“myBroadCast”, -1);

the majority of the code we’ve already covered. The key item here is : ns.play(myBroadCast, -1);

this code tells our netStream to play our broadcast.

So now if you test your viewer you should see your broadcast.

Enjoy sid

Great video walk through : Setting up new red5 application

21 May

Found a great walk through for setting up a new red 5 application :
http://www.newviewnetworks.com/nvnHome/blog/client/index.cfm/2006/5/12/Video-Demonstration-Creating-a-new-application-with-Red5

A few notes :

before you do anything make sure you have the java jdk installed. i removed jre and just let jdk re-install it. get it here : http://java.sun.com/javase/downloads/index.jsp
don’t forget to update red5 to your new java path
also after completing the walkthrough you’ll need to update 2 files to get everything working, both in your new applications WEB-INF folder

red5-web.properties @ webapp.contextPath=/myapp
webAppRootKey @ /myapp

cheers -sid

ok yeah and heres another helpful red5 link : http://flashextensions.com/tutorials.php

setup trac on media temple dv or centos with plesk installations

16 May

I covered svn setup on media temple dv and similar centos with plesk setups here : http://elsid.net/2007/05/07/setup-svn-server-on-media-temple-dv-or-centos-with-plesk/

Now i’ll cover the basics of setting up trac on media temple dv and similar centos with plesk setups. Please note this is what worked for me (and should work for other media temple dv setups). Please let me know if i missed something, or any recommendations.

first steps

First you need to request root access and the developer tools package. Once that’s done we’re ready to start.

This setup will use mysql for the trac database and serve trac from a subdomain. I’m only covering the setup of a vanilla trac installation

You can take a look at the trac install guide here : http://trac.edgewall.org/wiki/TracInstall

Preq’s / What you’ll need:

clear silver :

  • download – http://www.clearsilver.net/downloads/
  • setup docs – http://lists.edgewall.com/archive/trac/2005-December/006090.html
  • setup – ./configure, make, make install
  • setup tools :

  • download – http://svn.python.org/projects/sandbox/trunk/setuptools/#egg=setuptools-dev
  • setup docs – http://svn.python.org/projects/sandbox/trunk/setuptools/README.txt
  • setup – sh setuptools-0.6c4-py2.4.egg
  • mysqldb:

  • download – http://sourceforge.net/project/showfiles.php?group_id=22307
  • setup docs – http://blog.spikesource.com/mysqldb.htm
  • setup – python setup.py build, python setup.py install
  • python:

  • already installed
  • mod_python:

  • already installed
  • svn:

  • http://elsid.net/2007/05/07/setup-svn-server-on-media-temple-dv-or-centos-with-plesk/
  • More pre-install steps

    I covered svn setup here : http://elsid.net/2007/05/07/setup-svn-server-on-media-temple-dv-or-centos-with-plesk/

    svn must be rebuilt to work correctly with trac. http://trac.edgewall.org/ticket/3706#comment:10 .

    First we need to edit the svn makefile.
    change : SVN_APR_LIBS = /root/subversion-1.4.3/apr/libapr-0.la -lrt -lm -lcrypt -lnsl -lpthread -ldl
    to : SVN_APR_LIBS = /root/subversion-1.4.3/apr/libapr-0.la -lrt -lm -lcrypt -lnsl -lpthread -ldl -L/usr/lib -lgssapi_krb5 -lkrb5 -lk5crypto
    replace /root/subversion-1.4.3 with what ever is the path in your file.

    now run make clean, then make, and make install

    Almost done. We’ll build swig and then move to our trac setup. in your subversion build folder do the following.

    make swig-py
    make install-swig-py
    make swig-py install

    If you’ve installed all the preq’s, rebuilt svn, and built swig we should be ready to install trac.

    –note : you may need to copy the svn and libsvn folder from /usr/local/lib/svn-python to /usr/lib/python/site-packages. remember copy not move.

    Install trac

    Install Trac
    python ./setup.py install

    Setup Project

    go to plesk and setup a subdomain for trac. Make sure you only select python support.

    now setup a mysql database at the same domain you made your trac subdomain at. Add a user for this database and we’re almost home.

    make the following directorys :
    /var/www/vhosts/yourdomain/subdomains/yoursubdomain/trac/test
    /var/www/vhosts/yourdomain/subdomains/yoursubdomain/svn/test

    setup a project : trac-admin /var/www/vhosts/yourdomain/subdomains/yoursubdomain/trac/test initenv

    setup a test svn for this project : svnadmin create /var/www/vhosts/yourdomain/subdomains/yoursubdomain/svn/test

    make a sub directory in our trac directory and chmod 0777 it, we’ll need this later: mkdir /var/www/vhosts/yourdomain/subdomains/yoursubdomain/trac/plugins
    chmod 0777 /var/www/vhosts/yourdomain/subdomains/yoursubdomain/trac/plugins

    be sure to check the permissions on your svn and trac directory, we need to be sure apache is able to access and run our files.

    go to the conf directory for your subdomain : cd /var/www/vhosts/yourdomain/subdomains/yoursubdomain/conf

    almost done make a file : vhost.conf

    Open this file and add the following, remember to fix the paths to your domain and subdomain:


    SetEnv PYTHON_EGG_CACHE /var/www/vhosts/yourdomain/subdomains/yoursubdomain/trac/plugins
    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv /var/www/vhosts/yourdomain/subdomains/yoursubdomain/trac/test
    PythonOption TracUriRoot /
    PythonInterpreter main_interpreter

    Final Steps

    restart apache : /usr/local/psa/admin/sbin/websrvmng -a -v

    point your browser to your trac subdomain. If everything is working fine you’ll see a trac page. If not you’ll see a 500 error page.

    Got Problems?

    If your seeing an error page you should take the following steps:

    go to plesk >> yourdomain >> log manager >> error log

    copy the portion that contains your error and remove the servers timestamps and ip data.

    do a google on the very last line, this will contain the error message. You’ll likely see a result from the trac website. if not add the word trac before your search.

    If you still see no results from the trac website, go to the site and search the tickets. Still no luck? open a new ticket. Trac is very good with support and the community is extremely helpful.

    References / helpful Links

    http://trac.edgewall.org/wiki/TracGuide
    http://trac.edgewall.org/ticket/3706#comment:10
    http://trac.edgewall.org/ticket/4459#comment:21

    If you need help you can contact me, but i’d recommend using the trac community as i’m not fluent with python.

    happy coding – sid