ZLMediaKit is a domestic open source streaming media server, support for RTSP, RTMP, SRT and other mainstream live protocols, its installation instructions see the previous article "Linux environment to install ZLMediaKit to achieve video push streaming". Combined with ZLMediaKit and ffmpeg to achieve RTSP/RTMP protocols to push the streaming function, has been in the "Linux environment to install ZLMediaKit to achieve the video to push the streaming" article is described in detail, and here alone to explain how to achieve SRT protocols to push the streaming function of ZLMediaKit and ffmpeg.
ZLMediaKit already supports SRT by default during compilation and startup. Check the configuration file of ZLMediaKit and find the configuration information of srt section as follows, which shows that ZLMediaKit assigns port 9000 to SRT protocol by default.
Other than that, ZLMediaKit doesn't need to adjust any other configuration, just run the following ffmpeg command after startup to push video files to SRT address. Note, make sure FFmpeg on Linux server has integrated libsrt library, otherwise ffmpeg can't push stream to SRT address, for detailed integration steps, please refer to the previous article "Integrate libsrt and librist with FFmpeg in Linux environment".
Note that the second half of the srt address in the above command is "r=live/test,m=publish", where "r=live/test" means that the service name of SRT is called "live/test" and "m=publish" means that the address belongs to the publishing function, which is for the push streamer to use. live/test", and "m=publish" means that the address belongs to the publish function, which is for the push streamer to use.
ZLMediaKit also has requirements on the encapsulation format of the video source file, not only the source file is required to be ts format, but also the push stream format is also required to be ts format, so ffmpeg added "-f mpegts" to the command to convert to mpeg ts stream format. If the source file is not in ts format, or not converted to mpegts format, subsequent playback of srt links via ffplay will report the following error.
In addition, the audio and video encoding standards supported by ZLMediaKit are listed in src/Extension/, and the detailed audio and video support standards are shown below.
It can be seen that if the video file to be pushed for streaming does not belong to the above audio/video encoding standard, it will not be able to be pushed for streaming normally through the SRT service address.
After running ffmpeg's SRT Push Streaming command, ZLMediaKit outputs the following log message, which shows that its SRT Push Streaming function is running normally.
Then, according to the introduction of "FFmpeg Development in Action: From Zero Basics to Online Short Video" book "1.3 Windows System Installation of FFmpeg", install FFmpeg on your PC and open the command line of MSYS, run the following ffplay command, expecting to pull the streams from the SRT address. play. Note, make sure the FFmpeg on your computer has integrated libsrt library, otherwise ffplay will not be able to play srt links, see the previous article "Windows environment to FFmpeg integration libsrt" for detailed integration steps.
The above SRT streaming address is similar to the previous streaming address, except that the IP address is changed to the IP address of the external network, that is, the "m=publish" at the end of the link is changed to "m=request", in which request indicates that the request is also used to pull the stream party.
ffplay runs and pops up the player window and plays the video screen and sound normally. Also observe the service log of ZLMediaKit as shown below:
As seen from the above logs, ZLMediaKit has successfully implemented the SRT push-pull streaming feature for live video streaming via the SRT protocol.
For more details on FFmpeg development see