Outsourcing Consulting News
SolovatDesign is participating as an exhibitor at 2010 CTIA conference. Please visit us at the booth 3659
Open Source media server software development
- video streaming for linux, windows
The project is to develop an additional functionality for the existing software. That system was providing video streaming from web cameras in online mode. The initial functionality was providing video broadcasting in mpeg4 format, audio » in gsm.
The client contacted SoloSoft consulting to develop a service for viewing video through the flash player embedded into a web page, i.e. everything should be transmitted in flash supported format (video » h.263, audio » mp3).
Solution - Media Server software for video streaming services
Media server software was developed for video and audio streaming through the Internet. The solution itself is not an independent application and works as a part of the service responsible for video streaming. The system is a service that provides paid access to web cams for viewing video. The main page allows users to register and then select a "room"; he or she would like to watch. The "room" is connected to a web camera; at that, several people can watch video from this web camera simultaneously.
Initially, it was necessary to install an application for transmitting video to the computer with a web camera. It coded video into mpeg4 format and audio - into GSM format and then sent audio and video to the server as two separate streams. To get access to the service on the client side, it was necessary to install a Java applet, which received two streams from the server (audio and video separately) and then played it in the browser window.
In the course of operating the system, the following shortcomings were revealed:
Video stream decoding by means of Java applet is a resource-intensive process. Not high end computer users complained of large resource consumption by the applet;
Applet behavior could vary on different JRE versions;
Not all users had JRE installed on their computers. According to the site statistics, there were about 12% of such users.
Managers of the client company expected that company's income could be potentially increased up to 12%, if there were an opportunity of using such service by maximum number of users, not only having JRE installed on their PCs. As a solution, Flash technology was chosen for audio and video transmission from the server to the browser. At the same time, the existing service had already attracted a large number of permanent users who were satisfied with Java applet functionality. That is why it was decided to leave the possibility of access through the Java applet, and to add Flash support in such way that it would require as little as possible changes in already existing service functionality.
The client provided VideoServer's source codes that were analyzed and then the following changes were proposed. For video stream conversion to the flash format, it is necessary to encode video frames into h.263, and audio » into mp3 format. In addition, each frame should have flash frame header, and in front of frame there should be .flv file header. The header was formed in such way, that the file length was set at maximum possible. Thus, continuous video streaming can last for quite long period of time.
During broadcasting in flv format, a side effect was discovered - the browser stored received flv file in a temporary directory. Thus, a user had an opportunity to store videosession, while the client was not interested in such opportunity. As a solution of this problem, use of RTMP server was proposed. Among available RTMP servers (Adobe Flash Media Server, Red5 open source media server, Wowza Media Server) only Re5 server met the requirements. All available servers were oriented to the translation in rtmp video from the files, while it was necessary to receive video stream through the network. Taking into consideration that Red5 is an open server, its functionality can be extended to enable possibility of reading received from the VideoS erver .flv file from the socket.
Two libraries were used for frame conversion » libgsm (for GSM audio decoding) and libavcodec. In addition, we partially duplicated libavformat library functions that were responsible for flv-file and frame headers. It was necessary to rewrite them because the library itself was developed to work with files, and it was needed to transmit everything to the buffer for further sending through the socket.
Architecture of the developed media server software for video streaming services
The given solution consists of three parts:
Flash player. This part of the service is transmitted to the user browser in swf file, the link to which is placed in html-page. Swf file is interpreted and executed by Macromedia Flash plugin, which is supported by majority of browsers and is available for almost all most popular desktop operating systems. In addition, we added the possibility of advertising and informational messages scrolling in the creeping line during video transmission.
Modules for RTMP server that ensure receiving flm stream from the network and its transmission as rtmp stream. Also, we provided interaction with the billing system for control of users access to the services.
Video frames converter (mpeg4 -> raw video -> h.263) and audio converter (gsm -> raw audio -> mp3) were designed with the help of ffmpeg libraries and then integrated into existing videoserver code.
Tools and Technologies:
- C/C++, ActionScript, Java
- Red5: Open Source Flash Media Server
- library for working with audio in gsm format » libgsm
- library for decoding and coding video and audio » libavcodec
All Additional changes in functionality were successfully integrated into the original client system.
The content was provided without Java applet installation.