Two days ago want to write a script with Python, batch access to RTMP server, to achieve the effect of concurrent live, search on the network, there is a python-librtmp library can be used, but this library is not installed, do not want to waste too much time, and then give up (back to study).
Then with degrees Niang fine search, found FLAZR this tool, support rtmp concurrent live function, can be used for concurrent live pressure test, immediately download and put into use.
This tool supports the use of Win and Linux, respectively, to execute the. bat and. Sh scripts, as follows:
client.sh rtmp://ip:port/path-load-----> 200 Concurrent Requests
This tool is developed in Java and needs to be set up before using the JVM, otherwise the Java head error is prone to occur.
Directly open the. Sh script, set the JVM's mem according to its own situation, as follows:-----------------------------
This period of time has been in the SRS based on the live video service pressure test, is currently in the test scenario of concurrent push flow. &NBSP
The video live server uses the RTMP (real time messaging Protocol) protocol, and the target address of the push stream is similar to "Rtmp://0.0.0.1/path", in the context of the test, No more suitable for stress testing tools. Finally decided to use Python to develop scripts that can execute concurrent push streams. Initially, a Python third-party module, Rtmpy, was found on the web to support the RTMP protocol, but the module failed to install successfully. Later, I learned FFmpeg (a set of multimedia codec framework), which is a very powerful codec tool, there are many parameters available, just to meet my push and live test requirements. &NBSP
After further familiarity with FFmpeg, start thinking about combining ffmpeg with Python, and in a Linux environment, you can use the Os.popen () method in Python to execute the ffmpeg command. The following methods can be implemented for a push-flow scenario: &NBSP
def fun ():
Os.popen ("ffmpeg-re-i xxx.mp4-c copy-f flv Rtmp://0.0.0.0:1935/path 2>/dev/null ")
of course, it's just a simple implementation that uses FFmpeg to perform video stream push, and to achieve concurrent push, you must use Multiprogramming, where the best way to do this is to use the Python process pool. Is the pool that uses the multiprocessing module, such as:
poo = multilprocessing. Pool (Process = 5)
for x in rtmpaddrlist:
Pool.apply_async (Fun, (x,)) # "X" is the parameter in the incoming method fun. You can parameterize the FFmpeg command in fun so that you can implement a push operation on a different rtmp address
Pool.close ()
Pool.join ()
There are three more important scenarios for the stress test of a live video server. Concurrent live broadcast, concurrent push flow, concurrent live broadcast + concurrent push stream, these three scenarios can be used to achieve the stress test, of course, can not run too many concurrent processes in a test machine, preferably to prepare multiple test machines, Distribute concurrent processes evenly to each test machine, and then allow each test machine to start the script at intervals of time, so that not only can the stress test be realized, but the performance metrics of CPU, memory, IO can be measured with the increasing number of concurrent numbers in the video streaming server. Go from: http://blog.csdn.net/u011881908/article/details/45147535