An example of Flash Media Server (FMS) Application

Source: Internet
Author: User
ArticleDirectory
    • I. requirements are as follows:
    • Ii. Required Software
    • Iii. required hardware
    • IV. Implementation
    • 5. Notes
    • 6. Topic Extension
I. requirements are as follows:

Currently, a server administrator needs to record the game demo status through a camera. Client users can watch the game live broadcast through a browser, the server also provides a small window for the client to view the appearance of the live video (to avoid errors), and you can pause the video (fraudulent use ^-^). The client user thought it was just a network card, those who don't know what's going on! Flash on the server side, for example:

Ii. Required Software

(1) Macromedia Flash

Design flash on demandProgramOr ui ide, because the program discussed in this article is simple, you do not need to download specialized ActionScript development tools. If you really need it, select the official flex builder.

(2) Macromedia Flash Media Server (FMS)

The Flash multimedia server is used to broadcast multimedia files directly stored on the server as streams. These multimedia files can be in FLV, MP3, and other formats, another function of FMS is to receive and synchronize broadcast of live streams. Of course, I also know that it has many configuration options to control service behavior.

(3) IIS (optional)

If you develop an online video chat system, you need to deploy the entire program successfully. Apart from the above-mentioned FMS, of course, according to your system development language, it may not be IIS, it is Apache, or other server software.

TIPS:Macromedia has already been acquired by Adobe (Photoshop company) and can be used on the official website of adobe.

Iii. required hardware

A computer, a camera, and a microphone that act as both a server and a client (Optional). It is only used for testing ).

My camera is replaced by a mobile phone camera. I use a Symbian system smartphone, and then I use the mobiola web camera USB software to turn the mobile phone camera into a video camera and test it successfully (), qq video chat is also applicable. In addition, if you do not have an independent camera, but you have a mobile phone that can be used for photography, although it is not a smart phone, it may be used as a video camera, you can go back to the detailed instruction manual.

IV. Implementation

The specific implementation idea should be described as follows: there must be two Flash files, one deployed on the client (which can be viewed by netizens ), the Flash file at this end only needs to receive and play a specified live video file stream on the FMS. The server side is a little complicated. The local camera must be started at this end, and save the recorded video as a live stream to the FMS server (the live stream does not store the recorded video files on the FMS, this is applicable to scenarios where the live video lasts for a long time and the server does not have enough hard disk space. Of course, these video streams do not need to be backed up, which is different from the video recordings of banks or communities ), at the same time, the server also needs to check the video that the client actually sees, so there is also a video control instance for displaying the video stream instantly retrieved from the server, and there is also a control button, this command is used to control the stop and start recording of a video. For example, if the video source requested by the client user does not exist, the videosystemc.swf is blank. After the video is started, the video displayed in the videosystems.swf window at the server end is almost the same as that in the upper left corner. Because the photos I tested are on the same computer as the FMS, the video is faster, the user's end may be a little behind the screen shown in the small window.

Two Flash filesCode:

Specifically, loadtxt. Load ("videomsg.txt") is used as a variable in the videomsg.txt file under the same level directory. I didn't directly write it in the FLA file for convenience of future deployment. I just need to modify the notepad file and don't need to modify the animation source file. The content stored in videomsg.txt is serverurl = rtmp: // localhost/chat & playfilename = temvideo, here, "chat" is the name of an application directory created under the applications directory of the installation directory of the FMS. "temvideo" is the identifier used to store live streams on the FMS server, "localhost" is of course the server address, which is modified according to the actual situation.

(1 client videosystemc.swf


Stage. scalemode =   " Noscale " ;
Stage. showmenu =   False ;
VaR Loadtxt =   New Loadvars ();
Loadtxt. Load ( " Videomsg.txt " );
Loadtxt. onload =   Function (SUCCESS ){
If (SUCCESS ){
NC =   New Netconnection ();
NC. Connect (loadtxt. serverurl );
NC. onstatus =   Function (Info ){
If (Info. Code ! =   " Netconnection. Connect. Success " ){
If (Info. Code =   " Netconnection. Connect. Failed " ){
_ Root. msg. Text =   " Video Connection Failed ··· " ;
} Else   If (Info. Code =   " Netconnection. Connect. Rejected " ){
_ Root. msg. Text =   " The video connection is rejected by the server ··· " ;
} Else {
_ Root. msg. Text =   " The video is being connected ··· " ;
}
} Else {
_ Root. msg. Text =   "" ;
}
};
Res =   New Netstream (NC );
View. attachvideo (RES );
View. attachaudio (RES );
Res. Play (loadtxt. playfilename );
}
};

(2)server-side videosystems.swf


Stage. scalemode =   " Noscale " ;
Stage. showmenu =   False ;
VaR Loadtxt =   New Loadvars ();
Loadtxt. Load ( " Videomsg.txt " );
Loadtxt. onload =   Function (SUCCESS ){
If (SUCCESS ){
Views. attachvideo (camera. Get ());
Views. attachaudio (microphone. Get ());
NC =   New Netconnection ();
NC. Connect (loadtxt. serverurl );
NC. onstatus =   Function (Info ){
If (Info. Code ! =   " Netconnection. Connect. Success " ){
If (Info. Code =   " Netconnection. Connect. Failed " ){
_ Root. msg. Text =   " Video Connection Failed ··· " ;
} Else {
_ Root. msg. Text =   " The video is being connected ··· " ;
}
} Else {
_ Root. msg. Text =   "" ;
}
};
Nsout =   New Netstream (NC );
_ Root. BTN. Label =   " Start recording " ;
VaR Flag =   True ;
_ Root. BTN. onrelease =   Function (){
If (FLAG ){
Flag =   False ;
_ Root. BTN. Label =   " Stop recording " ;
Nsout. attachvideo (camera. Get ());
Nsout. attachaudio (microphone. Get ());
Nsout. Publish (loadtxt. playfilename, " Live " );
} Else {
Flag =   True ;
_ Root. BTN. Label =   " Start recording " ;
Nsout. attachvideo ( Null );
Nsout. attachaudio ( Null );
}
};
Res =   New Netstream (NC );
Viewc. attachvideo (RES );
Viewc. attachaudio (RES );
Res. Play (loadtxt. playfilename );
}
}; 5. Notes

1. After the MS is installed, you cannot log on to the server console through the Management Console with the correct Administrator account and password. The system always prompts "Failed Login Attempt ", this is probably caused by your firewall or anti-virus software. In my own installation environment, I installed "Kaspersky" and "360 security guard" on my computer. At first, I found that the login failed, later, I gradually exited "Kaspersky" and "360 security guard". After I quit "Kaspersky", I still failed to log on. Finally, I logged on to "360 security guard, this indicates that "360 security guard" is playing tricks.

2. If your flash file (SWF file) needs to communicate with the server or the Internet, it cannot be run directly. For security reasons, we can deploy it on the server, or set it as prompted.

3. If the Flash file you access needs to start the local camera, a prompt box will appear asking you if you want to allow the connection. Of course, you must choose to allow it because we are informed, there is no possibility of being photographed. It is said that there is a QQ video software, and the other party can see you without your knowledge by starting your camera. Flash is designed to prevent such incidents.

6. Topic Extension

The following describes the implementation principles of other video applications:

(1) live broadcast of online beauty:Live broadcast of beautiful women's own video to the majority of netizens, this beautiful girl can not see the video of netizens. This is similar to the example discussed in this article. At this time, the beauty acts as the server administrator. This article discussed the same thing on the same computer, but here, the beauty live broadcast application, the FMS cannot be on this beauty machine, she accesses the remote server through the IP address or domain name of the FMS server. At the same time, we do not want only one beauty to publish a video at a time, assign a video storage identifier to each user (You may usually use the ID account of this beauty member), and then store these video IDs in the database, you can simply read the live broadcast list of these online girls on the webpage. You can click to view the list of online beauty videos if you like.

(2) Two-way interactive video:Users and beautiful women can share videos with each other, which is similar to the commonly used video functions of QQ. At this time, it should be a one-to-one relationship. At this time, both the client and the server must start the camera and broadcast their own videos to the FMS server, when both parties call back the video, they can request the Flash file video source to the other party's source.

(3) network meeting:Network meetings are usually attended by more than two people, and everyone must be able to see others, the Flash images presented in front of each meeting Member should be composed of many small pictures. Each small picture corresponds to a meeting Member, and each camera and microphone must be available to each other, you must broadcast your video streams to the FMS. Then, the Flash file that each person accesses requests a video source from all the meeting members to be displayed locally. Obviously, this requires higher network speed or bandwidth. In fact, video services can be played by not a webmaster, and the cost is relatively high. Now, people like to watch high-definition video services. The video services you have developed are not high-definition and people do not like to watch them, in this way, you need to purchase hardware such as advanced video capture cards, in addition to buying expensive FMS servers and paying high bandwidth fees.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.