Archive for the ‘red5 tutorials’ Category

Red5 Webapps Online Application Generator

Sunday, August 29th, 2010

The Red5 Webapps Online Application Generator is a very simple but effective utility to generate Red5 application online. This application gives you the power to create red5 applications without having any knowledge of programming. You can generate streamer applications, with live broadcasting, streaming, recording and shared-Object capabilities in a single click. No compiling/editing needed.

The application takes configuration inputs using a simple flash based front end, and generated red5 application for you by injecting those information’s into a application template at runtime.

The generator is located here Red5/Webapps Application Generator.

How to use:

1. Select a Red5 application from the drop down list of available applications. You can read the description of the application in the description box, once you have selected a application.

2. Then enter the name of your rtmp application in the text input box provided below the application list drop down. (no spaces). This will be the context name that you will connect to : rtmp://server/appname

3. Below the description box, you will find the “Stream Directory Path” option. Use this to select between absolute/relative path schemes. This will set the location for recording/playing streams using the application.  In many cases where you may want the streams directory to be on a location other than the default streams folder under red5, you can use absolute path scheme to specify the path to your custom streams directory.

To select a path scheme select one of the radio buttons .

4. Enter appropriate relative/absolute paths in the text input boxes.

For absolute path scheme on linux file systems , use :      /home/……

For absolute path scheme  on windows use :                   c:/…..

* Relative path schemes remain same for linux and windows , though you wont use “../” to traverse backwards in either.

5. Press “Generate & Download” button to generate the specific application from its application template.

6. Press “ok” when your are prompted to download your application.

7. You may also want to read the description text to kn ow more about the selected application before generating your own copy.

Keep checking back for newly added Red5 applications at:

http://flashvisions.com/

How To Install RED5 version 0.8 or 0.9 on CENTOS

Sunday, January 17th, 2010

RED5 is open source flash server written in java supports streaming audio/video, recording client streams, shared objects, live stream publishing etc. In this short steps you can install red5 server on your virtual server or dedicated.

Download and Install Java

RED5 server depends on Java, so lets install it first using yum:

# yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

Download and Install Ant (Apache Project)

Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory. This step may cause problems because they all always updating the apache ant and changing the name of it, so sometimes the binary is called apache-ant-1.8.0RC1-bin.tar.gz sometimes apache-ant-1.8.0-bin.tar.gz so you will have to get the correct link, go to http://opensource.become.com/apache/ant/binaries/ and find what they have, get the one which ends on tar.gz, should be about 9-10 mega file, so edit the link down to the correct one;

# cd /usr/src
# wget http://opensource.become.com/apache/ant/binaries/apache-ant-xxxxx-bin.tar.gz    (replace apache-ant-xxxxx-bin.tar.gz with the correct file)
# tar zxvf apache-ant-xxxxx-bin.tar.gz   (replace apache-ant-xxxxx-bin.tar.gz witht he correct file)
# mv apache-ant-xxxxx/ /usr/local/ant     (pay attention, replace xxxxx with the correct version)

Export Variables for Ant and Java

# export ANT_HOME=/usr/local/ant
# export JAVA_HOME=/usr/lib/jvm/java
# export PATH=$PATH:/usr/local/ant/bin
# export CLASSPATH=.:$JAVA_HOME/lib/classes.zip

Also export these variables in /etc/bashrc to become available for every user login or for any terminal opens.

# echo ‘export ANT_HOME=/usr/local/ant’ >> /etc/bashrc
# echo ‘export JAVA_HOME=/usr/lib/jvm/java’ >> /etc/bashrc
# echo ‘export PATH=$PATH:/usr/local/ant/bin’ >> /etc/bashrc
# echo ‘export CLASSPATH=.:$JAVA_HOME/lib/classes.zip’ >> /etc/bashrc

Download and Install RED5 Server

Now we come to the main part, which one you want? 0.8, 0.9, 0.7??

you can find the various versions available at:

http://red5.googlecode.com/svn/java/server/tags/

if for example you want version 0.8, then the command would be:

svn co http://red5.googlecode.com/svn/java/server/tags/0_8_0/ red5

if you want the 0.9, then:

svn co http://red5.googlecode.com/svn/java/server/tags/0_9rc1/ red5

so lets say we take 0.8 version:

# cd /usr/src
# svn co http://red5.googlecode.com/svn/java/server/tags/0_8_0/ red5
# mv red5 /usr/local/
# cd /usr/local/red5
# ant prepare
# ant dist

you will see lots and lots of lines, but you should get at last

BUILD SUCCESSFUL

that’s mean its install and now copy the conf directory from dist/ and test the red5 installation.

# cp -r dist/conf .
# ./red5.sh

If it shows Installer service created in the last then everything is fine here, press ctrl+c

Now go to the red5 folder:

# cd /usr/local/red5/dist

command to stop red5:

# sh red5-shutdown.sh
sometimes it is better to use:
# killall -9 java

Command to start red5:

# cd /usr/local/red5/dist

# sh red5.sh &

When Red5 is running you should be able to access http://your-server-domain-or-ip:5080/ .

If it works first thing go to http://your-server:5080/installer/and install admin. Then to http://your-server:5080/admin/register.html and register an username and password. Then you can check application statistics anytime from http://your-server:5080/admin/ with server ip and the registered username, password.

RED 5 RESTART

You need to restart every time you add or update files in the /usr/local/red5/dist/webapps folder – where all applications should be installed.

red5 hosting or Real Time Messaging Protocol (RTMP) hosting

Friday, January 8th, 2010

Real Time Messaging Protocol (RTMP) is a protocol for streaming audio, video and data over the Internet, between a Flash player and a server. A special software is required to run on server side for accepting and serving the rtmp connections from flash clients. We provide managed RTMP hosting based on RED5.

Red5 is shared on our shared hosting plans that means although you can use red5 to stream your videos you will not have access to the red5 folder. Most scripts based on red5 need to upload a folder inside red5/webapps.

This folder is important because it will be on the RTMP path, ex.

rtmp://your-server-ip/folder-name

Contact us so we can upload your folder to red5/webapps and then give you the rtmp path.

RTMP Hosting

Could not reserve enough space for object heap

Wednesday, November 18th, 2009

While restarting the red5 service on the server, If you get following error

——————BEGIN SESSION——————
root@server [~]# cd /usr/local/red5/dist
root@server [/usr/local/red5/dist]#./red5.sh &
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
===============================

Then the best solution for this error is to use the following command. This command will increase the java heap size.

Quote:
root@server [/]#export _JAVA_OPTIONS=”-Xms20m -Xmx64m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:NewSize=10m -XX:MaxNewSize=10m -XX:SurvivorRatio=6 -XX:TargetSurvivorRatio=80 -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled”

Be sure that it ends with a ” if it is missing add it manually. Then restart the red5

Quote:

root@server [~]# cd /usr/local/red5/dist
root@server [/usr/local/red5/dist]#./red5.sh &

If you are facing same problem “Error occurred during initialization of VM” again and again on the server then the problem is with the ulimit setting. If it is a cpanel/WHM server then add the following code in the start of the /etc/profile file.

Quote:
#cPanel Added Limit Protections — BEGIN

#unlimit so we can run the whoami
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null

LIMITUSER=$USER
if [ -e "/usr/bin/whoami" ]; then
LIMITUSER=`/usr/bin/whoami`
fi
if [ "$LIMITUSER" != "root" ]; then
ulimit -n 100 -u 20 -m 200000 -d 200000 -s 8192 -c 200000 -v 200000 2>/dev/null
else
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi
#cPanel Added Limit Protections — END

Save and exit.

Log out and login again (or start another session) for these changes to take effect.

Red5 Tutorial and Red5 Hosting

Tuesday, September 22nd, 2009

Red 5 is a pretty amazing server software written in java. The Red 5 development team has put in tons of effort to make it a open source alternative to Adobe FMS – Flash Media Server.
Red 5 is a perfectly suitable technology for “Video On Demand” applications, streaming, publishing, mealtime collaboration, multi player gaming and more….
Red 5 is on all shared hosting plans of Hosting Marketers. By default the red5 server comes with some sample applications pre installed into it, like oflaDemo, fitcDemo, SoSample etc.

When installing and using red5 you have to keep in mind some configurations and security concerns. Red 5 was created to emulate the RTMP Protocol (realtime messaging).
Even today where many don’t know the capabilities of Red5 or are scared of the complications offered by java coding, i must tell you… once you get to use it you will love it :) .
There are many applications to be made with RTMP and many possibilities to be discussed. Here we will discuss a simple application that can stream from custom directory. This application will be server side and will help you set up your own basic application which does not require you to use the global oflaDemo.

Hosting Marketers offer you Red5 Hosting facility on their servers, which is needless to say … “amazing”.

You can host you own youtube or clipshare clones at a very nominal cost. However to avoid any problems, as you will be sharing resources on a shared server, its always better to create your own application, that accepts incoming outgoing requests.
This tutorial does not give you the scope to create the application from scratch, rather configure it to use a custom path on the server to stream from / record to . You can then safely use your own account path to handle streams. By default oflaDemo uses “streams” directory on the server to play/record streams.

Though this tutorial gives you a course on setting up the same, many have difficulties getting it done.
So here is the practical way of doing it.

I assume you already have basic Application class ready, which makes your application valid. We will simply use a custom filename generator to change the stream paths.

Setting up a custom Filename Generator: – CustomFilenameGenerator.java

package com.flashvisions;
import org.red5.server.api.IScope;
import org.red5.server.api.ScopeUtils;
import org.red5.server.api.stream.IStreamFilenameGenerator;
public class CustomFilenameGenerator implements IStreamFilenameGenerator {
/** Path that will store recorded videos. */
public static String recordPath;
/** Path that contains VOD streams. */
public static String playbackPath;
private String getStreamDirectory(IScope scope) {
final StringBuilder result = new StringBuilder();
final IScope app = ScopeUtils.findApplication(scope);
while (scope != null && scope != app) {
result.insert(0, “/” + scope.getName());
scope = scope.getParent();
}
return playbackPath + result.toString();
}
public String generateFilename(IScope scope, String name, GenerationType type) {
return generateFilename(scope, name, null, type);
}
public String generateFilename(IScope scope, String name, String extension, GenerationType type) {
String filename;
filename = getStreamDirectory(scope) + name;
if (extension != null)
// Add extension
filename += extension;
return filename;
}
public boolean resolvesToAbsolutePath() {
return true;
}
/* Setters for your path variables */
public void setPlaybackPath(String path) {
playbackPath = path;
}
public void setRecordPath(String path) {
recordPath = path;
}
}

Save this code in a file: CustomFilenameGenerator.java in the same package as your application class.
Now that we have setup the code , we need to make our application aware of the class so that it may
use the path values from this.
So we edit red5-web.xml. This one of the configuration files of red5. Generally the content or red5-
web.xml looks like this:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN”
“http://www.springframework.org/dtd/spring-beans.dtd”>
<beans>
<bean id=”placeholderConfig”
class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
<property name=”location” value=”/WEB-INF/red5-web.properties” />
</bean>
<bean id=”web.context”
autowire=”byType” />
<bean id=”web.scope”
init-method=”register”>
<property name=”server” ref=”red5.server” />
<property name=”parent” ref=”global.scope” />
<property name=”context” ref=”web.context” />
<property name=”handler” ref=”web.handler” />
<property name=”contextPath” value=”${webapp.contextPath}” />
<property name=”virtualHosts” value=”${webapp.virtualHosts}” />
</bean>
<bean id=”web.handler”
class=”com.flashvisions.Application”
singleton=”true” />
</beans>

The last bean instructs Red5 about the main application class. So just before the </beans>
closing tag .. we will add the directive for our CustomFilenameGenerator class.
So our final red5-web.xml will look like this:
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN”
“http://www.springframework.org/dtd/spring-beans.dtd”>
<beans>
<bean id=”placeholderConfig”
class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
<property name=”location” value=”/WEB-INF/red5-web.properties” />
</bean>
<bean id=”web.context”
autowire=”byType” />
<bean id=”web.scope”
init-method=”register”>
<property name=”server” ref=”red5.server” />
<property name=”parent” ref=”global.scope” />
<property name=”context” ref=”web.context” />
<property name=”handler” ref=”web.handler” />
<property name=”contextPath” value=”${webapp.contextPath}” />
<property name=”virtualHosts” value=”${webapp.virtualHosts}” />
</bean>
<bean id=”web.handler”
class=”com.flashvisions.Application”
singleton=”true” />
<bean id=”streamFilenameGenerator”>
<property name=”playbackPath”>
<value>C:\</value>
</property>
<property name=”recordPath”>
<value>C:\</value>
</property>
</bean> </beans>
As per the above example …all streams will be recorded to/played from my c: drive. You can set your
account path instead of c:/ to use your own folders for streaming.

This tutorial was writen by Rajdeep Rath from Flash Visions