At A Glance Main Projects Tutorials Resume

Messenger


There currently is no messenger. Manually, you can contact me via:
AIM: TecGumbo

Google Talk: palen1c at gmail.com

Twitter: @Technogumbo



Red5 Media Server Development Setup Tutorial


This tutorial was written in November, 2008 and covers one way of setting up the Red5 Flash Media Server in a Windows development environment. The intended audience is users that are familiar with Red5 and are interested in developing a custom application. If you just want to test red5, dont follow this tutorial. Instead grab one of the official releases at: http://code.google.com/p/red5/

Software Tools

1. Java SE Development Kit (JDK): http://java.sun.com/javase/downloads/index.jsp
2. Apache Ant: http://ant.apache.org/
3. Subversion: http://subversion.tigris.org/
4. Adobe Flash Player: http://www.adobe.com/products/flashplayer/

Before We Start:

Over a year ago I started working with Red5 which ultimately caused me to have to learn Flash development as well. If you are new to Red5 and new to Flash, its possible you will find this tutorial extremely frustrating as I probably would have a year ago. Your best bet of getting started with red5 is the flashextensions video tutorials. I understand that all the acronyms that come along with Java and flash are frustrating when trying to learn. Just stick with it, and you'll be a proffessional before you know it.

Step 1 - Install The Java Development Kit

A screencapture of the JDK download site
Red5 runs and is built on Java, the first step of setting up a development environment is getting the latest Java Development Kit. Java is notorious for using confusing acronyms in their product names. Currently the Java Development Kit goes by Java SE Development Kit. Just look for the download that contains the words "Development Kit" You can install the Java Development Kit (JDK) wherever you want, but you will need to know the exact path to the installation folder in later steps. I had an old version of the JDK on my computer, so I un-installed it and started with the newest version.

Step 2 - Set Windows Environment Variables for Java

A screencapture showing the pannel used to edit environment variables
After you have installed the JDK, the first thing to do is edit your Windows environment variables. Regardless if using Linux or Windows, the JAVA_HOME environment variable always needs to be set in order to ensure that other applications can see that java is installed. In all versions of Windows that I am familiar with , Environment Variables can be accessed via accessing the "My Computer" or "Computer" properties, then going to the "Advanced" tab / pannel. It should be noted that I am using Windows XP as a reference. Once in the Environment Variables dialog box, under the "System variables" list, click on the "New" button. For "Variable Name" put in JAVA_HOME. For "Variable Value" put in the exact OS specific path to the installation directory of the Java JDK. As an example, I made my Variable value: G:\java\jdk1.6.0_10

Step 3 - Install Apache Ant

The Apache Ant download page
This is the question I asked when I first had to use this tool. Apache Ant is a build tool for Java applications. It basically allows several java applications to be compiled at once. Its like a Windows batch script or a C++ makefile. The method of development with Red5 that I am showing uses Apache Ant in order to build the server and its associated applications using only one command and a build script.
When you go to the Ant website, get the .zip version of Ant and simply unzip it to a place on your hard drive. Just like the JDK, you need to know the exact path to Ant and specifically its bin directory.

Step 4 - Set Windows Environment Variables for Ant

Setting the ANT_HOME windows environment variable
Just like Java, Ant also requires Environment Variables to be set in order to ensure proper operation. Ant requires two variables. Just like Java, under the System variables section in Environment Variables, you should create a New variable. This time give it the Variable name "ANT_HOME" and a value of the directory it is installed (unzipped) in.

Setting the Path environment variable for apache ant
The second modification for ant is to add its bin directory to the "Path" System variable. If you scroll down under the "System variables" section you will see a variable named "Path" click on it and click "Edit". For Variable value, you will see several operating system directory paths separated by semicolons. You need to add the path to ants bin folder to this list.

For example, an exerpt from my Path Variable values reads:
C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\QuickTime\QTSystem\;
To add Ant to it, I would modify it to look like:
C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\QuickTime\QTSystem\;G:\java\apache-ant-1.7.1\bin;
In my case, Ant's bin directory is located at: G:\java\apache-ant-1.7.1\bin

Step 5 - Test Ant and Java at the Command Line

Testing java and ant using the command line
In order to make sure that we have installed the Java JDK and Ant correctly, open a command prompt window by going to start, run, and type cmd.
In the command prompt window first type "java" and you should see a whole bunch of usage parameters get listed. This means Java is installed correctly.
The next thing to type is "ant". You should see some dialog like "build.xml does not exist". This means ant is installed properly as well.
If for some reason, the java or ant commands aren't responding properly it probably means that you made an error while configuring the Environment Variables.

Step 6 - Install Subversion (SVN)

What is Subversion?
Subversion is a code version tool that allows multiple programmers to work on a project at the same time. Typically whoever is in charge of the project looks over the various code versions, the commits the best version to the "trunk" or main version of the application. If you see people talking about the Red5 "trunk", it means it is the main working version of the code.
We need subversion installed in order to get the latest main working version of the Red5 code. If you get a binary version of subversion that doesn't have an installer, make sure to add it to your Environment Variables so that it can be accessed from the command line.
There are various ways of getting subversion and I am not going to cover them in this tutorial, I hope not to your detriment.

Step 7 - Get the Trunk of Red5 from the Google Code Repository

Using SVN to get the latest red5 trunk from googlecode
Assuming that you have subversion installed; create a directory, that you want all the code from Red5 to go into. Open up the Windows command prompt; start, run, cmd. And change directories to the folder you just created. Also open up an Internet browser and navigate to the googlecode Red5 project page. (As of 2008, Red5's source is housed using googlecode)
Under the "Source" tab on the googlecode page, you'll find the subversion command line command to "checkout" or get the source code of the latest trunk of Red5. Reverberating the command on the googlecode page:
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5-read-only

When you run the command, you should see a list of files scroll down the screen as they are downloaded. You'll also notice the folder you ran the above command in start to become populated with files and directories.

Step 8 - Try to compile and run Red5 using Ant

The red5 build script using ivy to download dependencies from googlecode
Assuming all of the previous steps have worked, you are first entitled to a bit of congratulations. Now we get to move onto the fun stuff.
Open a command prompt and change directories to the folder that you just used svn to download all of the code into. You should see in the base red5 directory a file called "build.xml". This is the Ant build script for compiling Red5.
In order to compile the server, make sure your command prompt is at the location of the same directory that build.xml is located in. Simply run the command:
ant server

and you will see the build process start. You should see a large list of Google dependencies scroll by, some of which may be downloaded on the spot. During this process you may get firewall prompts from Java. Allow exceptions in your firewall. If all goes well you will continue to see things fly by in the console window until all the output stops and the last prompt will read. "Startup done in ", then it lists the milliseconds. As long as you leave this command prompt window open, Red5 will be running.

Step 9 - Test and Run Red5

The default red5 webpage that will run on localhost when compiling using ant
Assuming Red5 has started correctly, open an internet browser again and type in:





http://localhost:5080/

You should be presented with a Red5 webpage which has various links. If this doesnt work, we can still run the tests directly from their folders which I will explain shortly. A little ways down the page, you will see a message that says "Most of the demos must be installed first, click here to select the demos you want to install". This is different from the past, as the demos used to always come bundled with the code. In any case, click on the link to open the installer. If you didnt get anything when trying the localhost link mentioned above and you are certain red5 has compiled and is running, the swf for the demo application installer is located in: red5 code directory/webapps/installer

Step 10 - Install a Demo Application For Further Testing

The Red5 installer application that is used to downlod the example applications
When the installer first opens, just click on "Connect". The installer should connect and list all of the demo applications available. I would suggest that you install oflaDemo by simply highlighting its name and clicking Install. After the installation, if you look in the red5 install folder/webapps/ you should notice that a new folder "oflaDemo" has been created. The webapps folder is where all of the source code for Red5 applications is placed. When we run the ant build process, applications are compiled and copied from webapps to the dist folder.

After the installer is finished, it would be a good idea to stop Red5 and build it again. So in the command prompt window, make sure it has window focus and hit:
control + c

This will kill the Red5 server. Re-build the server simply by typing:
ant server

Assuming everything went well, you should be able to again navigate to:
http://localhost:5080/

This time click on the first link which talks about running Red5 demos. Click on the "view demo" link for OFLA Demo. If for some reason you cant get the web browser page again, the swf for OFLA Demo is located in webapps/root/demos

Flash Player security error when trying to connect to a local media server
When you first try and connect locally to your running Red5 server,
A successful build of Red5 running the oflaDemo application
you may get a Flash Player Security settings dialog that wont allow you to connect to localhost. If this occurs, then you have to go to the online Flash Player Global Security Settings panel and allow permissions to connect to your local red5 directory. If you are able to connect to the oflaDemo application, you should see the red5 console window acknowledge a connection then see a list of movie trailers you can stream. Click on a trailer name to stream it.

Step 11 - Solving Common Errors

Below I will list a few of the common errors I have seen recently and provide links to resources about fixing them. If none of these work for you, then please just be patient and stick with it. Red5 is a really fun tool to work with once you know how it works.

1. When trying to run the demo applications, you cant connect and the console window says "Closing RTMPMinaConnection from 127.0.0.1: to localhost with id ##### due to long handshake"

If you get the above error, its likely that you haven't installed the server instance of the demo application you are trying to connect to! Make sure you have used the installer to install the specific application you are trying to demo. Although the demos page lists and has all of the flash programs for the samples, the server doesn't come pre-installed with them if you download the source code version.

2. When trying to run the command "ant server" for the first time, you have problems with the googlecode dependencies and the build process fails.

As far as I understand, Red5 uses what is called "Ivy" to check for dependencies. I have had luck in the past clearing my ivy cache then trying to build the server again. Some of the details on this can be found in http://www.nabble.com/Groboutils-missing-again-td20095601.html Simply put, you can try and run the command:
ant ivyclear
then
ant server

which should make you start downloading .jar files again. I think this mainly happens when you have run previous versions of Red5 in the past on the same machine.

3. When trying to run any "ant" commands, you get the message ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME.
An incorrect ANT_HOME setting example


In this instance it means you have installed java correctly, but ant isnt setup correctly. Make sure you set both the ANT_HOME environment variable and also added the path to ant's bin folder to your system path.



Comments

Charles
Charles
September 21, 2012 4:08 pm

Hi Hendrik,

I haven't ever dealt with the authdemo specifically, but another great place to look that might help you find the issue is in the red5 logs folder. Besides the main logs there are usually application specific logs.

I don't have experience with the eclipse plugin, but if you start the server using batch scripts it used to print out the applications it has loaded as it loads them in the terminal. If you redirect the terminal output to a file temporarily, it might help too. To do this on a windows host in a command prompt open in the same folder as red5.bat you would do something similar to this.

red5.bat > red5StartupLog.txt

Then after you wait a while for the startup procedure to finish, you would have to kill the process with control + c in the command window.

I hope that helps a little.

hendrik
hendrik
September 21, 2012 07:02 am

Hi guys!

Since a couple of days I'm trying to get the red5 authdemo to work (in Eclipse Juno on OS X 10.7.2).

see: http://blog.infrared5.com/2012/05/red5-authentication/
demo-project source: http://dl.dropbox.com/u/7316897/ir5/blog/red5-auth.zip

The red5 Server seems to work fine but I've got that above-mentioned 'due to long handshake'-message a few seconds after trying to connect rtmp://localhost/authdemo via Flash Media Live Encoder 2.3

Is it possible that I haven't installed the authdemo application correctly?
In this case... how do I have to install a server instance?
Is there a way to check if authdemo works correctly?

Please reply right here or send an email to schnitzls.spamgmail.com

I appreciate every kind of help!

Thank you in advance!

Atik
Atik
September 17, 2012 06:29 am

Hi, I have installed red5 & started it . But when i try to install demos (http://localhost:5080/installer/) , it shows me "connecting..." & never ends . I have net connection Ok . Whats the problem ? please help me . I have installed latest : "Red5-1.0.0-RC2.exe" & jdk version 7 : "jdk-7u7-windows-i586.exe"

aravi
aravi
May 30, 2012 01:25 am

when it try to check out this is the error i receive please help me out

svn: E175002: Unable to connect to a repository at URL 'http://red5.googlecode.c
om/svn/java/server/trunk'
svn: E175002: OPTIONS of 'http://red5.googlecode.com/svn/java/server/trunk': cou
ld not connect to server (http://red5.googlecode.com)

Charles
Charles
April 16, 2012 11:12 pm

Thanks Twisty, Im glad you got it working! Just FYI - you dont need ant for any of the versions of Red5 if all you want to do is run it.

However if you want to re-build it from source code or build server side applications, youll need ant.

Twisty
Twisty
April 16, 2012 7:29 pm

Good post! I was installing to Win 2008 Server and this helped. FYI RC 1 does not require ant installed. If installing to Win 7/2008, follow these additional steps:
http://stackoverflow.com/questions/7969445/red5-test-page-wont-come-up?answertab=votes#tab-top

CinnaTech
CinnaTech
February 19, 2012 6:55 pm

Hello

CinnaTech
CinnaTech
February 19, 2012 6:46 pm

Hello,

My hosting company is a semi-managed hosting and I had the install red5 for me and they did then they came back and told me I need to configure the red5 to my requirements. I have no idea on how to do this I have messed up the server about 8 times and lost all my data and they had to reinstall the os for me over a months time. So Can anyone help me getting this configured so I can use it and I do not have to pay a red5 hosting company?

Thanks
cullin@dr.com

Charles
Charles
January 28, 2012 09:02 am

When you compile the server using ant, a dist folder is created, then the server is run out of that directory. I'd make sure your RED5_HOME environment variable is set to the right location. Also make sure if using Windows Vista+ that the UAC isn't preventing ant from creating directories.

January 28, 2012 02:54 am

After compiling red server using ant server command.I am getting the following.
compile-demos:
[echo] Webapps dir: webapps
[echo] Webapps build dir: dist/webapps
[copy] Warning: C:\Program Files\flash\trunk\deploy does not exist.
Also the i am not able to launch demo.Please help

Ronchy
Ronchy
January 15, 2012 9:49 pm

Awesome tutorial! I have a smooth installation by the way!!

I have read somewhere that you need only JDK 1.6 (JDK 6.0) in order to install the demos or else you will get a version mismatch error. Well, I'm trying it now

Thanks. :D

Charles
Charles
October 13, 2011 8:56 pm

Have you checked out the Google groups Red5 group and mailing list? There has been a lot of activity lately regarding mp4 files.

Qasim
Qasim
October 12, 2011 01:36 am

Hi
i have installed red5 server, it is running flv files, but not running mp4 and 3gp files.
it does not give any error too.

Anybody got idea about this.

Thanks in advace

Charles
Charles
October 10, 2011 10:40 am

Kasim,

By default ofla demo awlays loads with localhost in the connection string box. You need to manually type in any other IP address.

kasim
kasim
October 10, 2011 04:46 am

OS Windows Server 2008
Red5 0.9


Server ip address is 192.168.148.128

i connect it from 192.168.20.118

Everything works fine. when i click on connect from oflaDemo it gives me following error.

(5836) NetConnection.onStatus: level = error code = NetConnection.Connect.Failed


the problem is it still shows rtmp://localhost/oflaDemo, and i think it should have shown 192.268.248.128 which is the server in this case.

please help me .

Gireesh Kaushik
Gireesh Kaushik
September 23, 2011 10:07 am

Thnks for this post

Charles
Charles
May 25, 2011 10:16 pm

Hi again Chris. When red5 runs, it uses the tomcat http server to run a webpage that can be opened in a browser on port 5080.

If you are trying to connect to red5 using an actual flash application even running inside a webpage the syntax is a bit different. Let's assume I have used the installer application on red5 to install the classic oflaDemo application. In order to connect to that in a flash application, assuming the server is running locally, the syntax would be: rtmp://localhost/oflaDemo.

The rtmp protocol uses port 1935 by default (I think), so make sure local apps can connect to it.

Red5 is hard to use, but hopefully this will help you out.

chris
chris
May 23, 2011 12:13 am

Thanks Charles!

Well, I got red5 to run using command prompt and the last line says "Bootstrap complete". But can you direct me on how to run my client app. I'm using Eclipse IDE with the FlashBuilder plugin and when I try to run the Actionscript, an HTML page opens but its empty and doesn't seem to connect to my localhost:5080. I'm a red5 newbie so I'm not sure how to get my client running or if I'm missing a step in the deployment process.

Thanks,
chris

Charles
Charles
May 22, 2011 10:15 pm

Chris,

If you used one of the installers to install Red5 you don't need to use ant to re-build it. Ant is only when you're building the server from its source code when you are making server-side applications.

If you want to try and manually start Red5 on windows when it is already built, there is usually a red5.bat batch script you can just double click on, and it will start the server. The installers normally install red5 as a service too. Not sure about the latest builds though.

chris
chris
May 21, 2011 5:40 pm

Hi all,

Every time I try to test Red5, I type http://localhost:5080/ but the page tells me that I could not connect to localhost:5080. I know that Red5 is running and this is the output I'm getting in command prompt. I'm getting confused on the last part of the tutorial on how to install a demo for further testing. Can anyone help?

Cmd output: (towards the end)

C:\Program Files\Red5>red5
...

Setting default logging context: default
Logger context selector method found
Exception java.lang.ClassCastException: org.slf4j.helpers.BasicMDCAdapter cannot
be cast to ch.qos.logback.classic.util.LogbackMDCAdapter
Bootstrap complete

C:\Program Files\Red5>ant server
Notice:
Ant is not required, you are using a built version of Red5 which was installed u
sing one of our installers. Ant is used for compiling the server, which in this
case is already compiled.
Go here for more info: http://wiki.red5.org/
Thanks
Press any key to continue . . .

C:\Program Files\Red5>


Thanks,
chris

Rahul
Rahul
March 28, 2011 03:03 am

very nice tutorial, it helps me lot

Charles
Charles
February 23, 2011 10:25 am

Hi lsharma. There is already a decently mature project project called red5phone that does exactly what you're looking for.

http://code.google.com/p/red5phone/

If your looking for skype like performance, I would suggest taking a look at the XMPP protocol instead with its libjingle extensions that implement actual SIP and more standardized protocols.

lsharma
lsharma
February 23, 2011 01:02 am

hi,

Past many days i have been looking to find a solution for web based voice chat application... i found out that red5 will provide me the solution that will help users to chat with each other... is there any open source voice chat application avb....

Suryakant Maurya
Suryakant Maurya
February 18, 2011 06:25 am

Nice!!! very helpful..

Charles
Charles
January 18, 2011 11:48 pm

John,

You'll likely need to create a flash client side application to stream the live video. On the Red5 server side, the demo application oflaDemo can actually be used for the streaming. There are two really old Flash demos with Red5 called Simple Broadcaster and Simple Subscriber (You have to use the application installer to install them) that will do exactly what you are talking about.

If you want example code, you can use my Red5 Tuning application as a start that will broadcast and receive live streams from Red5. It's written in Flex.

http://www.technogumbo.com/projects/red5-tuning-application/index.html

john
john
January 17, 2011 1:40 pm

hi there
can you tell me how can I make a simple webcam broadcasting app using flash and red5? I need something that can show my webcam to a user on internet.
rply me at:
elton2jain{at}gmail.com

swamy
swamy
October 12, 2010 08:29 am

Hi,
I am suffering with red5 tooooomuch, please help me, I got like below error, when testing samples of red5 server

(1948) connected?: true
(2082) NetConnection.onStatus:
description = No scope 'oflaDemo' on this server.
code = NetConnection.Connect.Rejected
level = error


(2082) NetConnection.onStatus:
level = status
code = NetConnection.Connect.Closed

If your are able, send me mail to swamykumarv@rediffmail.com

Thanks for advance.

Edwin
Edwin
July 28, 2010 12:41 am

Thank you very much. Its very helpful to setup Red5 in my system.

Charles
Charles
June 23, 2010 2:34 pm

Oops. I meant 5080!

Charles
Charles
June 23, 2010 2:31 pm

Hi again Kashif.

You must have something already running on port 8080. On the command line of any Windows, Linux, or Mac machine you should be able to use the command "netstat -a -b" to see all of the binaries that are occupying your system's ports.

I haven't checked out the source of red5 in six months or so, but assuming the directory tree is still the same, you can change the configuration that runs tomcat on port 5080 in red5. This file can be found at:
conf/red5.properties . Under the HTTP section, you can change the port.

kashif
kashif
June 23, 2010 06:30 am

help needed

when i run project in eclipse it gives error of port in use 5080. how can i stop port i stop red 5 services manually i stop through red5-shutdown bat but it gives same error all the time 5080 port is in use so what to do.... ?

Charles
Charles
June 23, 2010 01:16 am

Kashif,

Sorry to hear you are very frustrated. Being frustrated and understanding Red5 go hand in hand.

The best resource I have seen lately are the videos on red5guide.com. I didn't watch all of them, but I think she assumes your using Eclipse, which I never do.

kashif
kashif
June 22, 2010 08:04 am

i have 3 main problems

1. the tutorials available on net are of old version of red5. so please if any one have latest tutorial link do send me.

2. when i create application it gives errors that build path is incomplete and it gives error on imports. as commons-logging file i'v download it but now it give errors there is no file or package is there in new version as mentioned in most of tutorials specialy it gives error in logging file.

3- i download commons logging package sepratly and include it to my project but now it gives error of

The type org.springframework.core.io.support.ResourcePatternResolver cannot be resolved. It is indirectly referenced from required .class files

so please do help me i realy need help GURUZ and Developers...

Niranjan Phadke
Niranjan Phadke
April 20, 2010 05:11 am

Thanks a lot for this.

Will you please help me modify and run java examples?

Thanks again.

Niranjan.phadke@gmail.com

iole
iole
February 14, 2010 11:39 am

Thanks ! It works perfect ! Juste for svn this one works perfectly [win vista] : http://subversion.tigris.org/files/documents/15/39559/svn-1.4.5-setup.exe

charles
charles
November 4, 2009 7:35 pm

Sorry that didn't help JaV. If you use "ant clean" it will delete all the compiled stuff and completely recompile everything. They try "ant server". Something I often do when I am making modifications to build.xml is to run "ant server > startuplog.txt" and then wait a while, run the commands that screw something up. They when you kill the server you will have the entire output of the startup sequence in the text file.

JaV
JaV
November 4, 2009 6:03 pm

Hi Charles, thanks for ur help but im still stuck. Its when im on http://localhost:5080/installer/, i click to install a sample, and it just hangs. I think the issue is caused by the build going wrong in step 8. I dont seem to be able to build it properly and i think that is causing trouble. If anyone can help i would really appreciate it. I am in desperate need of a working red5 server.

Charles
Charles
November 4, 2009 08:18 am

Hi JaV. In the Red5 root directory, take a look inside the dist folder. All applications before they run using this method should end up in the dist folder. Do you think it could be a permissions problem? Also, doesn't the command prompt show the URLs from where the applications are being downloaded from as its happening? Its possible that when you tried this, the server they are hosted on is having some difficulty?

JaV
JaV
November 4, 2009 00:22 am

Hi. I got through most of the setup, but at step 8 i got a build error. I had to type in ant ivyclear retrieve to get a successful build (I found this line on another site). This works, but when i get to step 10 and try to install demos, they start but never finish. It should only takes minutes but it never finishes for me so I assume there's a problem. Could you please help if u can coz i cant find any answers.

RGIA
RGIA
August 28, 2009 4:45 pm

T-H-A-N-K...UUUU 4-this posting!!! I am new to this stuff and your help has been INVALUABLE! Really appreciate you taking the time and having the heart to make my life ez!

bstephens
bstephens
August 6, 2009 3:54 pm

Nice tutorial! I was actually a bit confused by the normal Red5 docs, but this got me off the ground. Thanks!

Nizar
Nizar
June 25, 2009 11:38 am

Good job Guys Mate

Doug
Doug
June 22, 2009 06:56 am

Tried to build from within Flex Builder 3 and it almost worked but i have a couple of issues probably where JRE and Ant are coming via the Flex SDK... not sure still learning! but otherwise it's nice and easy to svn and checkout in Flex Builder (Subclipse). If i suss it i'll let you know. cheers

Doug
Doug
June 22, 2009 06:53 am

Nice work - all works for me as of June 09 with latest trunk source (0.8).

AnGeL-of-MeRcY
AnGeL-of-MeRcY
May 14, 2009 06:48 am

Thanx Mate nice post..!! :D

Comments are currently disabled.