怎么在 Linux 下运行 smart_rtmpd
怎么在 Linux 下运行 smart_rtmpd操作系统的准备
我们知道比较流行的 Linux 操作系统基本上分为两类,一类是以 Redhat 为基线的 Redhat, CentOS;另一类是 Debian 为基线的 Debian,Ubuntu。当然现在还有一些新兴势力 Arch Linux,但大家都是基于 Linux 内核进行封装运作的。主要表现是包管理器不同,面向的用户场景不同,有的往桌面方面发展,有的往嵌入式方向发展。这些系统大家可以根据自己的喜好进行选择,本文不做过多阐述,差异不大。建议大家采用操作系统最新版本,这样系统性能更好,功能更强大,兼容性更好,性能也是最佳。
smart_rtmpd 服务器软件的准备
[*]软件的下载
访问 https://github.com/superconvert/smart_rtmpd , 下载 https://github.com/superconvert/smart_rtmpd/blob/master/rtmpd.zip 或 https://github.com/superconvert/smart_rtmpd/releases
访问 https://gitee.com/superconvert/smart_rtmpd , 下载 https://gitee.com/superconvert/smart_rtmpd/blob/master/rtmpd.zip
[*]软件包的介绍
下载的软件包 rtmpd.zip 里面包含不同平台的安装运行包
smart_rtmpd.coroutines.centos7.7.1908.x64.tar.gz CentOS 系统的协程版本 (x64)smart_rtmpd.multithread.centos7.7.1908.x64.tar.gz CentOS 系统的多线程版本 (x64) --- 推荐smart_rtmpd.coroutines.ubuntu16.04LTS.x64.tar.gz Ubuntu 系统的协程版本 (x64)smart_rtmpd.multithread.ubuntu16.04LTS.x64.tar.gz Ubuntu 系统的多线程版本 (x64)smart_rtmpd.multithread.generic.aarch64.tar.gz ARM-v8 架构的多线程版本 (arm)
[*]软件包的准备
我们下载 rtmpd.zip 后进行解压,把 smart_rtmpd.multithread.centos7.7.1908.x64.tar.gz 上传到我们的 Linux 操作系统内,进行解压
# mkdir smart_rtmpd# tar zxvf smart_rtmpd.multithread.centos7.7.1908.x64.tar.gz -C smart_rtmpd# cd smart_rtmpd# ls -alhtotal 8.0Mdrwxr-xr-x. 3 root root167 Aug 15 05:34 .drwxr-xr-x. 4 root root 28 Aug 15 05:34 ..-rw-r--r--. 1 root root 9.7K Aug 14 18:12 config.xml-rw-r--r--. 1 root root378 Jul 23 12:24 gb28181.xmldrwxr-xr-x. 4 root root100 Aug 15 03:43 html-rw-r--r--. 1 root root234 Aug 172021 ice_server.json-rw-r--r--. 1 root root173 Feb 172023 mime.xml-rw-r--r--. 1 root root 2.8K Jul42021 policy.xml-rw-r--r--. 1 root root 1.6K Aug92021 server.crt-rw-r--r--. 1 root root 1.7K Aug92021 server.key-rwxr-xr-x. 1 root root 8.0M Aug 15 04:08 smart_rtmpd // 确保 smart_rtmpd 是可执行的为什么选用 smart_rtmpd.multithread.centos7.7.1908.x64.tar.gz 版本,这个应该是通用版本,应该适用用大部分 Linux 系统,无论是 CentOS, Ubuntun, Arch Linux
[*]运行 smart_rtmpd
我们准备运行 smart_rtmpd 流媒体服务器
问题1 :smart_rtmpd 没有可执行权限,通过 chmod 赋权# ./smart_rtmpd-bash: ./smart_rtmpd: Permission denied // 大部分这种情况是 smart_rtmpd 拷贝复制过程中丢失了可执行权限# chmod +x ./smart_rtmpd问题2 :端口被其它程序占用,需要通过 config.xml 更改端口,或者停止其它的程序# ./smart_rtmpd EAB7D740 I: smart_rtmpd --- build time : 2024-08-15 04:06:58EAB7D740 I: website url : http://www.qiyicc.com/download/rtmpd.zipEAB7D740 I: gitee url : https://gitee.com/mirrors/smart-rtmpdEAB7D740 I: github url : https://github.com/superconvert/smart_rtmpdEAB7D740 I: liveshow url : https://github.com/superconvert/smart_rtmpd/blob/master/liveshow.mdEAB7D740 I: development url : https://github.com/superconvert/smart_rtmpd/blob/master/web_dev.mdEAB7D740 I: examples url : https://github.com/superconvert/smart_rtmpd/tree/master/exampleEAB7D740 I: email : cwf12345@sina.comEAB7D740 I: webchat : 99766553, qq : 99766553EAB7D740 I: 192.168.161.136 ens33EAB7D740 I: ssl client no config.EAB7D740 I: ssl server no config.EAB7D740 I: the rtmp server ip: 0.0.0.0, port is: 1935EAB7D740 I: the http server ip: 0.0.0.0, port is: 8080generating new self-signed cert for smart_rtmpd@qiyicc.comEAB7D740 I: rtc-manager build self-signed certificate.EAB7D740 I: the rtsp server ip: 0.0.0.0, port is: 8554EAB7D740 I: the srt server ip: 0.0.0.0, port is: 9000EAB7D740 I: srt bind socket failed(Connection setup failure: unable to create/configure SRT socket)// 端口被别的程序占用了EAB7D740 I: srt bind socket failed.EAB7D740 I: the rtmp server stopEAB7D740 I: the http server stopEAB7D740 I: the rtsp server stop正常运行日志打印# ./smart_rtmpd 48AEE740 I: smart_rtmpd --- build time : 2024-08-15 04:06:5848AEE740 I: website url : http://www.qiyicc.com/download/rtmpd.zip48AEE740 I: gitee url : https://gitee.com/mirrors/smart-rtmpd48AEE740 I: github url : https://github.com/superconvert/smart_rtmpd48AEE740 I: liveshow url : https://github.com/superconvert/smart_rtmpd/blob/master/liveshow.md48AEE740 I: development url : https://github.com/superconvert/smart_rtmpd/blob/master/web_dev.md48AEE740 I: examples url : https://github.com/superconvert/smart_rtmpd/tree/master/example48AEE740 I: email : cwf12345@sina.com48AEE740 I: webchat : 99766553, qq : 9976655348AEE740 I: 192.168.1.102 ens33 // 我们的服务器地址48AEE740 I: ssl client no config.48AEE740 I: ssl server no config.48AEE740 I: the rtmp server ip: 0.0.0.0, port is: 193548AEE740 I: the http server ip: 0.0.0.0, port is: 8080generating new self-signed cert for smart_rtmpd@qiyicc.com48AEE740 I: rtc-manager build self-signed certificate.48AEE740 I: the rtsp server ip: 0.0.0.0, port is: 855448AEE740 I: the srt server ip: 0.0.0.0, port is: 900048AEE740 I: the sip server ip: 0.0.0.0, port is: 506048AEE740 I: the ims server ip: 0.0.0.0, port is: 6666这样 smart_rtmpd 就表示正确运行起来了!!!
推流拉流的验证
[*]推流例子
RTMP 推流
ffmpeg -re -stream_loop -1 -i 33.mp4 -vcodec libx264 -acodec aac -f flv rtmp://192.168.1.102:1935/rec/streamRTMP 推流 ( HEVC )
ffmpeg -re -i 1.mp4 -c:a copy -c:v libx265 -f flv rtmp://192.168.1.102:1935/live/hevc怎么让 ffmpeg 支持 hevc 推流 怎么编译 ffmpeg 让其支持 hevc(h265) - superconvert的个人空间 - OSCHINA - 中文开源技术交流社区
RTSP 推流
ffmpeg -re -stream_loop -1 -i 1.mp4 -vcodec libx264 -acodec aac -f rtsp rtsp://192.168.1.102:8554/live/streamRTSP 推流 ( HEVC )
ffmpeg -re -stream_loop -1 -i video-h265.mkv -vcodec libx265 -acodec aac -f rtsp rtsp://192.168.1.102:8554/live/streamSRT 推流
ffmpeg -re -i 22.mp4 -vcodec libx264 -acodec aac -f mpegts srt://192.168.1.102:9000?streamid=192.168.1.102:9000/live/stream,role=publisherSRT 推流 ( HEVC )
ffmpeg -stream_loop -1 -re -i video-h265.mkv -vcodec libx265 -acodec aac -f mpegts srt://192.168.1.102:9000?streamid=192.168.1.102:9000/live/stream,role=publisher
[*]拉流例子
RTMP 拉流
ffplay rtmp://192.168.1.102:1935/live/streamHTTP-HLS 拉流
ffplay http://192.168.1.102:8080/live/stream.m3u8HTTP-DASH 拉流
ffplay http://192.168.1.102:8080/live/stream.mpdRTSP 拉流
ffplay rtsp://192.168.1.102:8554/live/streamSRT 拉流 ( ffplay )
ffplay srt://192.168.1.102:9000?streamid=192.168.1.102:9000/live/stream,role=player
更多的推拉流例子请参阅博客 https://blog.csdn.net/freeabc/article/details/117403471?spm=1001.2014.3001.5501
对于支持 Enhanced-rtmp 的 HEVC 推流,需要使用 smart_rtmpd 的收费版本,目前 ffmpeg 从版本 6.1 开始就支持 Enhanced-rtmp 的 HEVC 推流和拉流!!!
[*]smart_rtmpd 的日志查看# ./smart_rtmpd 4F136740 I: smart_rtmpd --- build time : 2024-08-15 04:06:584F136740 I: website url : http://www.qiyicc.com/download/rtmpd.zip4F136740 I: gitee url : https://gitee.com/mirrors/smart-rtmpd4F136740 I: github url : https://github.com/superconvert/smart_rtmpd4F136740 I: liveshow url : https://github.com/superconvert/smart_rtmpd/blob/master/liveshow.md4F136740 I: development url : https://github.com/superconvert/smart_rtmpd/blob/master/web_dev.md4F136740 I: examples url : https://github.com/superconvert/smart_rtmpd/tree/master/example4F136740 I: email : cwf12345@sina.com4F136740 I: webchat : 99766553, qq : 997665534F136740 I: 192.168.161.136 ens334F136740 I: ssl client no config.4F136740 I: ssl server no config.4F136740 I: the rtmp server ip: 0.0.0.0, port is: 19354F136740 I: the http server ip: 0.0.0.0, port is: 8080generating new self-signed cert for smart_rtmpd@qiyicc.com4F136740 I: rtc-manager build self-signed certificate.4F136740 I: the rtsp server ip: 0.0.0.0, port is: 85544F136740 I: the srt server ip: 0.0.0.0, port is: 90004F136740 I: the sip server ip: 0.0.0.0, port is: 50604F136740 I: the ims server ip: 0.0.0.0, port is: 66661FFFF700 I: rtmp-none(obj: 0x7f8534000900, ip: 192.168.161.1:60252) set in_chunk_size to 600001FFFF700 I: rtmp-publisher(obj: 0x7f8534000900, ip: 192.168.161.1:60252) stream connected.1FFFF700 I: rtmp-manager add application(obj: 0x7f8518001e40, url: rtmp://192.168.161.136/live/stream)!1FFFF700 I: rtmp-app(obj:0x7f8518001e40, url: rtmp://192.168.161.136/live/stream) add http-hls(0x7f8518004de0)1FFFF700 I: rtmp-app(obj:0x7f8518001e40, url: rtmp://192.168.161.136/live/stream) add http-dash(0x7f8518005f30)1FFFF700 I: rtsp-manager add application(obj: 0x7f851800bd60, url: rtsp://192.168.161.136:8554/live/stream)!1FFFF700 I: rtsp-manager add publisher(obj: 0x7f851800b480, url: rtsp://192.168.161.136:8554/live/stream)!1FFFF700 I: rtmp-app(obj:0x7f8518001e40, url: rtmp://192.168.161.136/live/stream) add rtsp(0x7f851800b480)1FFFF700 I: srt-manager add application(obj: 0x7f851800f950, url: srt://192.168.161.136:9000/live/stream)!1FFFF700 I: srt-manager add publisher(obj: 0x7f851800e610, url: srt://192.168.161.136:9000/live/stream)!1FFFF700 I: rtmp-app(obj:0x7f8518001e40, url: rtmp://192.168.161.136/live/stream) add srt(0x7f851800e610)1FFFF700 I: rtmp-manager add publisher(obj: 0x7f8534000900, url: rtmp://192.168.161.136/live/stream)!1FFFF700 I: rtmp-publisher(obj: 0x7f8534000900, ip: 192.168.161.1:60252) build elapse 142 ms.1FFFF700 I: rtmp-publisher(obj: 0x7f8534000900, ip: 192.168.161.1:60252) amf_cmd unsupport _checkbw1FFFF700 I: rtmp-publisher(obj: 0x7f8534000900, ip: 192.168.161.1:60252) publish stream4D4F8700 I: rtmp-app(obj:0x7f8518001e40, url: rtmp://192.168.161.136/live/stream) inital video(h264 size:1000x562 fps:15)4D4F8700 I: rtmp-app(obj:0x7f8518001e40, url: rtmp://192.168.161.136/live/stream) inital audio(aac sample:44100 channel:2 bit:16) // 推流成功3D7FA700 I: rtmp-none(obj: 0x7f85340211d0, ip: 192.168.161.1:60259) amf_cmd unsupport _checkbw3D7FA700 I: rtmp-manager add player(obj: 0x7f85340211d0, url: rtmp://192.168.161.136/live/stream)!3D7FA700 I: rtmp-player(obj: 0x7f85340211d0, ip: 192.168.161.1:60259) build elapse 84 ms3D7FA700 I: rtmp-player(obj: 0x7f85340211d0, ip: 192.168.161.1:60259) play stream4D4F8700 I: rtmp-player(obj: 0x7f85340211d0, ip: 192.168.161.1:60259) inital video meta(sps) // 拉流成功
收尾工作
通过上述工作,我们的 smart_rtmpd 流媒体服务器能正常工作了,让我们来真正运行它吧,是不是操作特别简单,下载,解压,运行即可!
# ./smart_rtmpd -d // 参数 -d 表示以后台模式运行# tail -f log/20241231.log // 可以查看日志Good luck!
页:
[1]