Streaming media server ZLMediaKit and FFmpeg

overview

Keywords: ZLMediaKit, FFmpeg, srt, vlc

If you want to quickly have your own streaming media server, you can build it yourself using open source projects. Open source streaming media servers, in China, GitHub has a relatively high number of stars: srs and ZLMediaKit. Because I use Mediakit at work, I will introduce this open source streaming media server.

This article will talk about pushing streams to mediakit through ffmpeg and using vlc to pull mediakit video streams.

Environmental preparation

media kits

It is most convenient to use docker when deploying, but its docker image is relatively large, about 400~500MB. If you care about the size, you can compile it yourself. If you compile it yourself, the final executable file is only 11MB.

#此镜像为github持续集成自动编译推送,跟代码(master分支)保持最新状态
docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master

1935 is rtmp, 8080 is http interface, 8443 is https, 8554 is rtsp, 10000 is rtp, 8000 is rtc, 9000 is srt

ffmpeg

johnvansickle.com/ffmpeg/ Download the appropriate version here. After installation, use ffmpeg -protocols to view the protocols supported by ffmpeg. Check whether it supports the srt protocol, because I want to use the srt protocol to push and pull the stream.

vlc

www.videolan.org/vlc/ Just download the corresponding version.

Video preparation

ssyoutube.com/en156Bz/you… Go to YouTube and download a good video.

Push video stream to mediakit

After we download the video we like from YouTube, we can push it to mediakit through ffmpeg. For example, I downloaded Jay Chou's "Still Wandering" and then pushed it to mediakit using the srt protocol.

./ffmpeg -re -stream_loop -1 -i "/opt/still_wandering.mp4" -c copy -f mpegts 'srt://127.0.0.1:9000?streamid=#!::r=live/test,m=publish'

About mediakit support for srt

Then our mediakit receives this srt stream, and we call the http interface it provides: getMediaList

The default configuration of mediakit will convert the streams pushed to it to protocols such as rtmp, rtsp, hls, etc. We can pull this stream through the streaming media protocol it converted.

vlc pull video stream

Use vlc to pull the stream from mediakit. The srt protocol is somewhat special, and you need to configure the stream parameters on vlc.

For example, if we just pushed ffmpeg to stream live/test, then this configuration is enough. Then fill in the srt address:


192.168.16.152 is the mediakit server ip.

For other protocols, such as we use rtmp:


rtsp:

conclusion

That’s it for this article. It mainly talks about how to have your own streaming media server. Use the open source project ZLMediaKit as the streaming media server and use the srt protocol to push the stream. Use vlc to pull the live video stream on the streaming server.

As a benefit for this article, you can receive free C++ audio and video learning materials package + learning route outline, technical videos/codes, including (audio and video development, interview questions, FFmpeg, webRTC, rtmp, hls, rtsp, ffplay, codec, push-pull streaming, srs )↓↓↓↓↓↓See below↓↓Click at the bottom of the article to get it for free↓↓

Guess you like

Origin blog.csdn.net/m0_73443478/article/details/135243637