Introduction
Red5 is an open-source flash streaming media server developed using Java. It supports: Converting audio (mp3) and video (FLV) into playing streams; recording client playback streams (only FLV); Sharing objects; releasing live streams; remote calls. Red5 uses RSTP as the streaming media transmission protocol. In some of its examples, it demonstrates some basic functions such as online recording, flash streaming media playback, online chat, and video conferencing.
Software Environment
Since it is developed in Java, JDK must be installed. JDK 6.x is used here, red5 is 0.9.1, and red5 is embedded with the Tomcat 6.x server. In order to test and use red5, you need to build a development environment, develop and deploy the corresponding server-side applications, and develop the IDE eclipse3.3.x + myeclipse6.x (it seems that the version is a little low and there is no way to install the program on your computer, I don't want to download it any more, and it's enough at the same time, haha). The web server is Tomcat 6.x, and the client player uses flowplayer3.2.x. The following are red5 and flowplayer3.2.x.
Red5: http://www.red5.org/downloads/
Flowplayer http://flowplayer.org/download/
Install software and environment configuration 1. Install JDK
This example uses jdk-6u21-windows-i586.exe. Double-click and follow the prompts to install jdk-6u21-windows-i586.exe.
Set the environment variables java_home, path, and classpath. Google or Baidu
2. Install red5
For Windows environment, the download is setup-red5-0.9.1.exe. Double-click the installer to install it. During the installation process, you must enter the Server IP address and port. Because it is a local test, enter 127.0.0.1 directly. The port is free of charge and does not conflict with each other. We recommend that you set the port to 1024, use 5050 here. Do not forget to set the red5_home environment variable after installation.
By default, the red5 installer registers red5 as a system service and automatically starts the system service to check whether the service already exists:
We can see that the service has been installed but has not been started. We need to manually start it. Select red5 Service, right-click it, and choose start or restart. Do not repeat the operation on the system interface. If there is no accident, it should be able to start normally. If it cannot be started, check whether the preceding environment variable settings are complete and correct. Finally, check the red5 startup log file to see if the corresponding prompt information exists, the log file is under the log directory under the red5 main directory. There are multiple log files. You can view the red5_service.log file. After it is started, open the browser and enter the IP address and port used to install red5. Normally, the following information is displayed, indicating that red5 has been correctly installed.
In this case, you can click Install to download its official demo for research and learning. The installed demo file is under webapps under the red5 root directory, such as D: \ red5 \ webapps. The installation operation is relatively simple. I will not introduce it in detail here, but I would like to remind you that after the demo is installed, You need to restart the red5 server. For details, refer to the above introduction.
3. install and configure the development environment
Install and configure eclipse3.3.x + myeclipse6.x + tomcat6.x.
The eclipsedownload file is eclipse3.3.1.zip, which is directly decompressed to the D: \ Program filesdirectory ;tomcatdownload apache-atat-6.0.36-windows-x86.zip, directly decompress it to D: \ folder, and double-click the prompt to install it.
Configure Tomcat server and default character set as UTF-8
So far, the software installation and environment configuration are complete, and the next step is to develop and deploy our Streaming Media Server Applications and test applications.
4. Download The flowplayer streaming media player.
Flowplayer is a Web-based video player developed with flash. It can be easily integrated into any web page. Supports HTTP and streaming media transmission. In addition to the player, the control bar component and the rtmp plug-in are also included. In addition, the player is extended to the jquery plug-in, and the jquery library is also required for use, version 1.7 +. The detailed list is as follows:
Backup after download
Development and deployment of streaming media applications 1. Development and deployment of server applications
Open myeclipse and create a webproject named vedio.dafangxiaoche.com. Then, add the deployment configuration for it.
Create a new streams directory under the vedio.dafangxiaoche.com project to store streaming media files, and then find some streaming media files such as FLV, MP4, and MP3, I copied several FLV files from the demo project provided by red5, and then copied a MP4 File locally.
Next, in the project's WEB-INF directory, new red5-web.properties, red5-web.xml, Web. xml file (can also be copied from the official demo, I directly copy .). The content of the three files is as follows:
Red5-web.properties files:
Webapp. contextpath =/Vedio
Webapp. virtualhosts = *,
Localhost, localhost: 8088,127.0 .0.1: 8088
Red5-web.xml files:
<? Xmlversion = "1.0" encoding = "UTF-8"?>
<! Doctypebeanspublic "-// spring // DTD bean // en" http://www.springframework.org/dtd/spring-beans.dtd ">
<Beans>
<Beanid = "placeholderconfig" class = "org. springframework. Beans. Factory. config. propertyplaceholderconfigurer">
<Propertyname = "location" value = "/WEB-INF/red5-web.properties"/>
</Bean>
<Beanid = "Web. Context" class = "org. red5.server. Context"
Autowire = "bytype"/>
<Beanid = "Web. Scope" class = "org. red5.server. webscope"
Init-method = "register">
<Propertyname = "server" ref = "red5.server"/>
<Propertyname = "parent" ref = "Global. Scope"/>
<Propertyname = "context" ref = "Web. Context"/>
<Propertyname = "handler" ref = "Web. Handler"/>
<Propertyname = "contextpath" value = "$ {webapp. contextpath}"/>
<Propertyname = "virtualhosts" value = "$ {webapp. virtualhosts}"/>
</Bean>
<Beanid = "Web. Handler"
Class = "org. red5.server. Adapter. applicationadapter"
Singleton = "true"/>
</Beans>
Web. xml file:
<? Xmlversion = "1.0" encoding = "UTF-8"?>
<Web-appversion = "2.5" xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd>
<Display-Name> vedio server </display-Name>
<Context-param>
<Param-Name> webapprootkey </param-Name>
<Param-value>/Vedio</Param-value>
</Context-param>
<Welcome-file-List>
<Welcome-File> index.html </welcome-File>
<Welcome-File> index. jsp </welcome-File>
</Welcome-file-List>
</Web-app>
Careful friends may notice that,
The contents of webapp. contextpath and webapprootkey in red5-web.properties, Web. xml file are both/Vedio, Corresponds to the directory configured in the previous deployment.
At this point, a simple server is complete and can be deployed under the red5 server. Because the deployment parameters have been configured earlier, there are two deployment methods available, for example, "Redeploy. Do not forget to restart the red5 server.
2. develop and deploy Client Applications
Like creating a server-side application, create a web project named www.dafangxiaoche.com under myeclipse. You can also configure the deployment parameters to the previously installed Tomcat server or manually, manually configure Tomcat here. Go to the installation root directory of tomcat6.x, Open Server. XML in the conf directory, and configure a Host:
Host is configured here. Do not forget to add it in the c: \ windows \ system32 \ drivers \ etc \ hosts file.
Next, add the flowplayer player and its corresponding and dependent components to the project (see the previous introduction for details on the file list), and then create the client application page. A new index.html page is directly created in the project root directory. The content is as follows:
<! Doctypehtml>
<Head>
<! -Here jquery uses 1.9.x -->
<Scriptsrc = "/JS/jquery. Min. js"> </SCRIPT>
<! -Introduce flowplayer -->
<Scriptsrc = "/flowplayer-3.2.x/flowplayer-3.2.11.min.js"> </SCRIPT>
<Scripttype = "text/JavaScript">
$ (Function (){
$ F ("A. rtmp", "/flowplayer-3.2.x/flowplayer-3.2.15.swf ",{
Clip:
{
Provider:
'Rtmp'
, AutoPlay:
False
},
Plugins :{
Rtmp:
{
URL:
"/Flowplayer-3.2.x/flowplayer.rtmp-3.2.11.swf ",
// Connection address of the streaming media application server. Note that the directory here is/vedio, which is consistent with the previous configuration.
Netconnectionurl:
'Rtmp: // localhost/vedio'
},
Controls :{
// Control bar plug-in
URL: '/flowplayer-3.2.x/flowplayer.controls-3.2.14.swf'
}
}
});
});
</SCRIPT>
</Head>
<Body>
<Div
Style = "width: 600px; Height: 400px;">
<
Class = "rtmp"
Href = "festival.mp4"> </a>
</Div>
</Body>
3. Test the application
Now, you can start atat6.x to test our application. Enter the address in the browser:
Http://www.dafangxiaoche.com/
At this point, a simple red5-based streaming media service application is developed and deployed, and the video is successfully played.
Summary
The player and red5 are just a preliminary understanding, which is equivalent to a helloworld. Although a video can be played successfully while downloading and freely dragging the progress bar, the playback speed is a little faster, and when dragging the feeling will jump forward, playing the artist and album information MP3 (http://stackoverflow.com/questions/12560414/error-red5-server-to-streaming-files-who-include-cover-art-or-album-art-in-java) exceptions and other issues, these are to be further understood and resolved.