Live555 简介
Live555是一个开源项目,是一个为流媒体提供解决方案的跨平台C++开源项目,实现了对标准流媒体传输协议(如RTP/RTCP,RTSP,SIP等)的支持。
官网
项目源码地址
编译Live555
使用的系统
➜ ~ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
编译前需要安装下编译工具链
下载源码
wget http://live555.com/liveMedia/public/live555-latest.tar.gz
解压
# 解压
tar -xf live555-latest.tar.gz
进入目录
cd live
修改配置文件
修改配置文件config.linux-64bit,添加-std=c++20,不修改的话编译会报错
生成Makefile并编译
./genMakefiles linux-64bit
make -j 4
可以看到在mediaServer目录下生成了二进制文件
测试
我们使用live555播放h264视频进行测试
生成h264文件
我们可以使用ffmpeg从视频文件中获取h264
ffmpeg -i nana.mp4 -vcodec copy -an nana.h264
将h264文件拷贝到mediaServer目录
注意文件名后缀为.264
cp nana.h264 live/mediaServer/nana.264
启动服务
➜ mediaServer ./live555MediaServer
LIVE555 Media Server
version 1.13 (LIVE555 Streaming Media library version 2025.01.17).
Play streams from this server using the URL
rtsp://192.168.0.38/<filename>
or
rtsp://[2408:8214:2a1d:2db1:922b:34ff:feeb:9991]/<filename>
where <filename> is a file present in the current directory.
Each file's type is inferred from its name suffix:
".264" => a H.264 Video Elementary Stream file
".265" => a H.265 Video Elementary Stream file
".aac" => an AAC Audio (ADTS format) file
".ac3" => an AC-3 Audio file
".amr" => an AMR Audio file
".dv" => a DV Video file
".m4e" => a MPEG-4 Video Elementary Stream file
".mkv" => a Matroska audio+video+(optional)subtitles file
".mp3" => a MPEG-1 or 2 Audio file
".mpg" => a MPEG-1 or 2 Program Stream (audio+video) file
".ogg" or ".ogv" or ".opus" => an Ogg audio and/or video file
".ts" => a MPEG Transport Stream file
(a ".tsx" index file - if present - provides server 'trick play' support)
".vob" => a VOB (MPEG-2 video with AC-3 audio) file
".wav" => a WAV Audio file
".webm" => a WebM audio(Vorbis)+video(VP8) file
See http://www.live555.com/mediaServer/ for additional documentation.
(We use port 80 for optional RTSP-over-HTTP tunneling).)
使用vlc播放视频进行测试
输入视频URL地址
点击播放
遇到的错误
错误一
编译时候会出现如下错误
BasicTaskScheduler.cpp: In member function ‘virtual void BasicTaskScheduler::SingleStep(unsigned int)’:
BasicTaskScheduler.cpp:191:40: error: ‘struct std::atomic_flag’ has no member named ‘test’
191 | if (fTriggersAwaitingHandling[i].test()) {
| ^~~~
make[1]: *** [Makefile:41: BasicTaskScheduler.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/root/live/BasicUsageEnvironment'
make: *** [Makefile:38: all] Error 2
解决办法
原因是默认配置不支持C++20,修改配置文件config.linux-64bit,添加-std=c++20