introduction
Streaming media file is one of the most popular network media formats. This file allows users to download and play at the same time, which greatly reduces the user's waiting time. In addition, when streaming media files are played over the network, the files themselves will not be stored in the local disk, which saves a lot of disk space overhead. It is these advantages that make streaming media files widely used in network playback.
Streaming media server publishes streaming media content and manages user connections by establishing publishing points. The streaming media server can publish the live stream transmitted from devices such as video capture card or camera, or publish the pre stored streaming media file, and publish the combination of live stream and streaming media file. A media stream can be composed of one media file, multiple media files, or a media file directory.
Flash Media Server, or FMS for short, is a member of the flash family, It is called the current development of Web audio and video applications (for example, video chat room, video conference system, podcast system, audio and video message, etc.) is the most convenient and fastest solution. It is also more and more widely used in web application development. Of course, FMS is not provided to users for free. The price of thousands of dollars per point discourages many developers. So, let's open it Start trying to find a more suitable solution, and the open source Red5 has become a new favorite.
Red5 is an open source Flash streaming media server developed in Java, which is similar to FMS in function. It supports: converting audio (MP3) and video (FLV) into playback streams; recording client playback streams (only FLV is supported); shared object; live streaming publishing; remote calling. Red5 uses RSTP as the streaming media transmission protocol, including online recording, Flash streaming media playback, online chat, video conference and other basic functions. Streaming media application products based on red5 are also being promoted at home and abroad, such as online video conference, Openmeeting and large Flash online games King 2.
Red5 overview
Red5 is an open source Flash streaming media server developed in Java. Free and open source makes the software easier to expand. After downloading, you can modify the source code; It is more economical. Compared with the high cost of FMS, red5 can save a lot of costs for general applications; At the same time, the server-side java object-oriented language is more mature than the FMS server-side ActionScript2 language. In view of the advantages of red5, it was soon accepted by the majority of users.
Red 5 support:
1. Convert audio (MP3) and video (FLV, F4V, MP4, 3GP) into playback stream;
2. Record the client playback stream and save the audio and video recording from the camera and microphone to the server;
3. Shared objects;
4. Live broadcast stream release;
5. Remote call;
6. Protocol: RTMP, RTMPT, RTMPS, and RTMPE.
Red5 server setup
JDK self installation
Download Red5
https://github.com/Red5/red5-server/releases
Unzip it to a folder you can remember eg:F:\Red5
Configure Red5 related parameters
Modify red5 Properties configuration file \conf\red5.properties
You only need to configure the host and port of HTTP and RMTP nodes. The default host is 0.0 0.0 enter LAN IP or 127.0 0.1 can be accessed normally
# Socket policy policy.host=0.0.0.0 policy.port=843 # HTTP http.host=0.0.0.0 http.port=8855 https.port=5443 http.URIEncoding=UTF-8 http.max_keep_alive_requests=-1 http.max_threads=20 http.acceptor_thread_count=10 http.processor_cache=20 # RTMP rtmp.host=0.0.0.0 rtmp.port=1935 rtmp.io_threads=16 rtmp.send_buffer_size=65536 rtmp.receive_buffer_size=65536 rtmp.ping_interval=1000 rtmp.max_inactivity=60000 rtmp.max_handshake_time=5000 rtmp.tcp_nodelay=true rtmp.tcp_keepalive=false rtmp.default_server_bandwidth=10000000 rtmp.default_client_bandwidth=10000000 rtmp.client_bandwidth_limit_type=2 rtmp.bandwidth_detection=false rtmp.encoder_base_tolerance=5000 rtmp.encoder_drop_live_future=false # traffic optimization hinting. to disable set traffic class set to -1 # low delay + high throughput == 24 (0x18) rtmp.traffic_class=-1 # requested maximum length of the queue of incoming connections rtmp.backlog=32 # the interval (seconds) between each throughput calculation rtmp.thoughput_calc_interval=15 # enable use of the default mina acceptor rtmp.default_acceptor=true # socket i/o pool sizes used when default acceptor is disabled rtmp.initial_pool_size=0 rtmp.max_pool_size=2 rtmp.max_processor_pool_size=16 rtmp.executor_keepalive_time=60000 mina.logfilter.enable=false # scheduler configs (per application) rtmp.scheduler.pool_size=16 rtmp.deadlockguard.sheduler.pool_size=16 # message executor configs (per application) - adjust these as needed if you get tasks rejected rtmp.executor.core_pool_size=4 rtmp.executor.max_pool_size=32 rtmp.executor.queue_capacity=64 # drop audio packets when queue is almost full, to disable this, set to 0 rtmp.executor.queue_size_to_drop_audio_packets=60 # maximum amount of time allotted to process a single rtmp message / packet in milliseconds, set it as 0 to disable timeout rtmp.max_handling_time=2000 # connection tweaks - dont modify unless you know what you're doing rtmp.channel.initial.capacity=3 rtmp.channel.concurrency.level=1 rtmp.stream.initial.capacity=1 rtmp.stream.concurrency.level=1 rtmp.pending.calls.initial.capacity=3 rtmp.pending.calls.concurrency.level=1 rtmp.reserved.streams.initial.capacity=1 rtmp.reserved.streams.concurrency.level=1 # RTMPS rtmps.host=0.0.0.0 rtmps.port=8443 rtmps.ping_interval=5000 rtmps.max_inactivity=60000 rtmps.max_keep_alive_requests=-1 rtmps.max_threads=20 rtmps.acceptor_thread_count=2 rtmps.processor_cache=20 # RTMPS Key and Trust store parameters rtmps.keystorepass=password rtmps.keystorefile=conf/keystore.jks rtmps.truststorepass=password rtmps.truststorefile=conf/truststore.jks # RTMPT rtmpt.host=0.0.0.0 rtmpt.port=8088 rtmpt.ping_interval=5000 rtmpt.max_inactivity=60000 rtmpt.max_handshake_time=5000 rtmpt.max_keep_alive_requests=-1 rtmpt.max_threads=20 rtmpt.acceptor_thread_count=2 rtmpt.processor_cache=20 rtmpt.encoder_base_tolerance=5000 rtmpt.encoder_drop_live_future=true # better setting for streaming media rtmpt.target_reponse_size=32768 # best setting for small messages or shared objects #rtmpt.target_reponse_size=8192 # max incoming messages to process at a time. the most that FP appears to send is 166 rtmpt.max_in_msg_process=166 # max time in millis that we will wait when offering data to the in or out queue rtmpt.max_queue_offer_time=125 # max offer attempts rtmpt.max_queue_offer_attempts=4 # WebSocket ws.host=0.0.0.0 ws.port=8081 # Debug proxy (needs to be activated in red5-core.xml) proxy.source_host=127.0.0.1 proxy.source_port=1936 proxy.destination_host=127.0.0.1 proxy.destination_port=1935 # JMX jmx.rmi.host=localhost jmx.rmi.port=9999 jmx.rmi.sport=9998 jmx.rmi.port.remoteobjects= jmx.keystorepass=password jmx.mina.monitor.enable=false jmx.mina.poll.interval=1000 # Whether to always create the registry in-process, not attempting to # locate an existing registry at the specified port. Set to "true" in order # to avoid the overhead of locating an existing registry when you always intend # to create a new registry in any case. jmx.registry.create=true # Whether or not the MBeanServerFactoryBean should attempt to locate a running # MBeanServer before creating one jmx.reuse.existing.server=true # Whether to register the MBeanServer with the MBeanServerFactory, making it # available through MBeanServerFactory.findMBeanServer() jmx.register.factory=true # Whether any threads started for the JMXConnectorServer should be started as daemon threads jmx.daemon=true # Whether the JMXConnectorServer should be started in a separate thread jmx.threaded=true # Server properties # max events to send in a single update so.max.events.per.update=64 so.scheduler.pool_size=4 keyframe.cache.entry.max=500 war.deploy.server.check.interval=600000 fileconsumer.delayed.write=true fileconsumer.queue.size=120 subscriberstream.buffer.check.interval=5000 subscriberstream.underrun.trigger=100 broadcaststream.auto.record=false
Start Red5
Double click red Bat to start the Red5 server
Visit the browser to check whether the setup is successful
http://localhost:port(localhost and port are set in the configuration file), as shown in the following figure

Ready for live video
Download demo
In the figure above, you can see the red line of install. Click in. Select OLFA installation

If the download is not successful, please see here
Make sure there is no oflaDemo folder under webapps. Download Xiaoshuai, decompress the prepared compressed package and put it in
Download address link: https://pan.baidu.com/s/1Qd0UggtEhBv5nbVxQGPSzQ Password: 4xqf
Set information publishing and broadcasting
Enter the publishing settings interface: http://localhost:port/demos/publisher.html

View the Settings area. After selecting Video, select the camera in the Device and click Start to display the Video screen (you may be prompted whether to allow it. Select allow)

Server settings
Return to the Server screen and enter in Location rtmp://localhost:1935/oflaDemo , address and red5 The RTMP protocol settings in properties must be the same. Click Connect

NetConnection appears on the right Connect. Success indicates that the connection to the server is successful.

Push video stream
Switch to Video and click Publish on the Publish page to Publish the live broadcast
View video stream
Switch to the Server and click play to view the pushed video stream

Watch the live broadcast on your own page
jwplayer is required. For your convenience, it has been put in oflaDemo. You can download it from the baidu cloud link above.
Modify the value of the relevant content file to be the value of the Name of the live broadcast page. streamer is the URL in the Location
<html> <head> <title>Red5 - OFLADemo</title> <script type='text/javascript' src='jwplayer.js'></script> </head> <body> <div id="player"> <script type='text/javascript'> jwplayer('player').setup({ 'flashplayer': 'player.swf', 'file': 'Of live broadcast page Name', 'streamer': 'rtmp://IP of your own service: 1935 / oflademo ', 'controlbar': 'bottom', 'width': '848', 'height': '360' }); </script> </div> </body> </html>
View with browser
Enter address http://localhost:port/oflaDemo/jwPalyer.html You can view it

The above is the steps to build the Red5 server