咸鱼

咸鱼是以盐腌渍后,晒干的鱼

0%

Live555搭建流媒体服务器

Live555提供HTTP/RTSP协议的多媒体流服务器和RTSP流代理中转。

下载源码编译

需要g++编译环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ wget  http://www.live555.com/liveMedia/public/live555-latest.tar.gz
$ tar -xzvf live555-latest.tar.gz
$ cd live
$ ls
BasicUsageEnvironment config.iphoneos config.solaris-32bit liveMedia
config.armeb-uclibc config.iphone-simulator config.solaris-64bit Makefile.head
config.armlinux config.linux config.uClinux Makefile.tail
config.avr32-linux config.linux-64bit configure mediaServer
config.bfin-linux-uclibc config.linux-gdb COPYING proxyServer
config.bfin-uclinux config.linux-no-openssl COPYING.LESSER README
config.bsplinux config.linux-with-shared-libraries fix-makefile testProgs
config.cris-axis-linux-gnu config.macosx genMakefiles UsageEnvironment
config.cygwin config.macosx-no-openssl genWindowsMakefiles win32config
config.cygwin-for-vlc config.mingw genWindowsMakefiles.cmd win32config.Borland
config.freebsd config.openbsd groupsock WindowsAudioInputDevice
config.freebsd-no-openssl config.qnx4 hlsProxy
$ ./genMakefiles linux-64bit #linux-64bit这个参数是config.<后缀>获取得到的,是编译的目标平台
$ make

启动服务

编译成功,在 mediaServerproxyServer 目录里面有可执行文件

1.mediaServer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ cd mediaServer
$ ./live555MediaServer
LIVE555 Media Server
version 1.00 (LIVE555 Streaming Media library version 2020.06.25).
Play streams from this server using the URL
rtsp://192.168.0.223:8554/<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 8000 for optional RTSP-over-HTTP tunneling, or for HTTP live streaming (for indexed Transport Stream files only).)

在此目录放一个test.mkv文件,用VCL播放器打开 http://192.168.0.223:8000/test.mkv 或者 rtsp://192.168.0.223:8554/test.mkv 就能播放了。

2.proxyServer

live555ProxyServer rtsp流源地址 &

1
2
3
4
5
6
7
8
9
10
11
12
$ cd proxyServer
$ ./live555ProxyServer rtsp://192.168.0.188:554/stream/main & #执行命令后会返回一个分发的流地址
./live555ProxyServer rtsp://192.168.0.188:554
LIVE555 Proxy Server
(LIVE555 Streaming Media library version 2020.06.25; licensed under the GNU LGPL)

Created new TCP socket 4 for connection
RTSP stream, proxying the stream "rtsp://192.168.0.188:554"
Play this stream using the URL: rtsp://192.168.0.223:8554/proxyStream

(We use port 8000 for optional RTSP-over-HTTP tunneling.)

3. test

拷贝一个.264测试视频文件到/live/testProgs目录下,live555网站可以下载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
$ ./testOnDemanRTSPServer
"mpeg4ESVideoTest" stream, from the file "test.m4e"
Play this stream using the URL "rtsp://192.168.0.226:8554/mpeg4ESVideoTest"

"h264ESVideoTest" stream, from the file "test.264"
Play this stream using the URL "rtsp://192.168.0.226:8554/h264ESVideoTest"

"h265ESVideoTest" stream, from the file "test.265"
Play this stream using the URL "rtsp://192.168.0.226:8554/h265ESVideoTest"

"mpeg1or2AudioVideoTest" stream, from the file "test.mpg"
Play this stream using the URL "rtsp://192.168.0.226:8554/mpeg1or2AudioVideoTest"

"mpeg1or2ESVideoTest" stream, from the file "testv.mpg"
Play this stream using the URL "rtsp://192.168.0.226:8554/mpeg1or2ESVideoTest"

"mp3AudioTest" stream, from the file "test.mp3"
Play this stream using the URL "rtsp://192.168.0.226:8554/mp3AudioTest"

"wavAudioTest" stream, from the file "test.wav"
Play this stream using the URL "rtsp://192.168.0.226:8554/wavAudioTest"

"amrAudioTest" stream, from the file "test.amr"
Play this stream using the URL "rtsp://192.168.0.226:8554/amrAudioTest"

"vobTest" stream, from the file "test.vob"
Play this stream using the URL "rtsp://192.168.0.226:8554/vobTest"

"mpeg2TransportStreamTest" stream, from the file "test.ts"
Play this stream using the URL "rtsp://192.168.0.226:8554/mpeg2TransportStreamTest"

"aacAudioTest" stream, from the file "test.aac"
Play this stream using the URL "rtsp://192.168.0.226:8554/aacAudioTest"

"dvVideoTest" stream, from the file "test.dv"
Play this stream using the URL "rtsp://192.168.0.226:8554/dvVideoTest"

"ac3AudioTest" stream, from the file "test.ac3"
Play this stream using the URL "rtsp://192.168.0.226:8554/ac3AudioTest"

"matroskaFileTest" stream, from the file "test.mkv"
Play this stream using the URL "rtsp://192.168.0.226:8554/matroskaFileTest"

"webmFileTest" stream, from the file "test.webm"
Play this stream using the URL "rtsp://192.168.0.226:8554/webmFileTest"

"oggFileTest" stream, from the file "test.ogg"
Play this stream using the URL "rtsp://192.168.0.226:8554/oggFileTest"

"opusFileTest" stream, from the file "test.opus"
Play this stream using the URL "rtsp://192.168.0.226:8554/opusFileTest"

"mpeg2TransportStreamFromUDPSourceTest" stream, from a UDP Transport Stream input source
(IP multicast address 239.255.42.42, port 1234)
Play this stream using the URL "rtsp://192.168.0.226:8554/mpeg2TransportStreamFromUDPSourceTest"

(We use port 8000 for optional RTSP-over-HTTP tunneling.)

用VCL播放器打开 rtsp://192.168.0.226:8554/h264ESVideoTest

错误解决

缺少ssl

1
2
3
4
5
6
7
8
9
include/TLSState.hh:31:10: fatal error: openssl/ssl.h: No such file or directory
#include <openssl/ssl.h>
^~~~~~~~~~~~~~~
compilation terminated.
Makefile:32: recipe for target 'RTSPServer.o' failed
make[1]: *** [RTSPServer.o] Error 1
make[1]: Leaving directory '/home/cn/live/liveMedia'
Makefile:35: recipe for target 'all' failed
make: *** [all] Error 2

解决:

1
2
3
4
#centos
$ sudo yum install openssl-devel
#ubuntu
$ sudo apt-get install libssl-dev