# RTSP 服务器/客户端配置文档 RTSP(Real Time Streaming Protocol,实时流传输协议),RFC2326,是一个 L7 应用层协议,由哥伦比亚大学、网景和 RealNetworks 公司提交的 IETF RFC 标准。 RTSP 是用来控制声音或影像的多媒体串流协议,允许同时多个串流需求控制(Multicast),既可以降低 Server 的网络带宽,又进而支持多方视讯会议(Video Conference)。另外,RTSP 还具有重新导向功能,可视实际负载情况来转换提供服务的服务器,以避免过大的负载集中于同一服务器而造成延迟。 RTSP 传输时所用的 L4 协议并不在其定义的范围内,Server 可以自行选择使用 TCP 或 UDP 来传送串流内容,它的语法和运作方式与 HTTP 1.1 类似,因此 RTSP 同样适用于 Proxy 和 Cache 场景。区别在于 RTSP 并不特别强调时间同步,所以比较能容忍网络延迟;另外,RTSP 支持双向发起请求,Client 和 Server 都可以发出请求。 ## Linux RTSP Server - live555 ``` sudo apt-get install libssl-dev wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz tar xzf live555-latest.tar.gz cd live ./genMakefiles linux-64bit make cd mediaServer $ ./live555MediaServer LIVE555 Media Server version 1.09 (LIVE555 Streaming Media library version 2021.04.06). Play streams from this server using the URL rtsp://192.168.1.109/ where 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).) ``` 这样就启动了一个 RTSP Server,列出了所有支持的视频格式(不支持 MP4)。 我们将下载的 MP3 文件复制到与 live555MediaServer 可执行文件的同一个目录下,然后即可通过 `rtsp://192.168.1.109/` 的方式来访问了。 ## Android RTSP Client - VLC for Android ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210415192045142.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0ptaWxr,size_16,color_FFFFFF,t_70)