做室內(nèi)意向圖的網(wǎng)站免費(fèi)seo推廣公司
RTSP系列:
? ? ? ??RTSP系列一:RTSP協(xié)議介紹-CSDN博客
? ? ? ??RTSP系列二:RTSP協(xié)議鑒權(quán)-CSDN博客?
????????RTSP系列三:RTP協(xié)議介紹-CSDN博客?
????????RTSP系列四:RTSP Server/Client實戰(zhàn)項目-CSDN博客?
目錄
一、RTSP Server實戰(zhàn)項目
1、準(zhǔn)備
2、simple-rtsp-server下載編譯
3、運(yùn)行
4、拉流測試
二、RTSP Client實戰(zhàn)項目
1、編譯
2、測試
一、RTSP Server實戰(zhàn)項目
????????地址:https://github.com/BreakingY/simple-rtsp-server
????????使用epoll,支持RTP OVER UDP、RTP OVER TCP,支持H264/H265、AAC/PCMA、支持鑒權(quán)。
1、準(zhǔn)備
????????simple-rtsp-server依賴ffmpeg,版本要求>=4.x。支持系統(tǒng):Linux
????????依賴安裝:
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
匯編庫:
sudo apt-get install yasm
sudo apt-get install nasm視頻庫:
sudo apt-get install libx264-dev
sudo apt-get install libx265-dev音頻庫:
sudo apt-get install libfdk-aac-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install libopus-dev
? ? ? ? ?ffmpeg源碼下載:
wget https://ffmpeg.org//releases/ffmpeg-4.0.5.tar.bz2tar xjvf ffmpeg-4.0.5.tar.bz2cd ffmpeg-4.0.5
????????編譯安裝:
./configure --prefix=/usr/local --enable-libx264 --disable-x86asm --enable-nonfree --enable-libfdk-aac --enable-shared --enable-gpl --enable-libmp3lame --enable-libopus --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/libmakemake install
2、simple-rtsp-server下載編譯
git clone https://github.com/BreakingY/simple-rtsp-server.gitcd simple-rtsp-servermkdir buildcd buildcmake ..make -j
3、運(yùn)行
cp -r ../mp4path ../rtsp_server 0 (0-不鑒權(quán);1-鑒權(quán))
4、拉流測試
??項目中mp4path自帶了測試文件,后面把想回放的視頻放到mp4path中即可
TCP拉流:
ffmpeg -rtsp_transport tcp -i "rtsp://192.168.10.17:8554/test_h264_aac.mp4" -vcodec copy -acodec copy test_h264_aac_tcp.mp4UDP拉流:
ffmpeg -i "rtsp://192.168.10.17:8554/test_h264_aac.mp4" -vcodec copy -acodec copy test_h264_aac_udp.mp4
????????也可通過VLC直接播放,點擊媒體->打開網(wǎng)絡(luò)串流,輸入rtsp地址即可。默認(rèn)是udp拉流,要使用TCP需要打開工具->偏好設(shè)置->輸入/編解碼器,拉到最下方,選擇“RTP over RTSP(TCP)”
????????rtsp_server程序會把rtsp信令交互過程打印出來,讓我們對rtsp信令交互過程更加清晰。
二、RTSP Client實戰(zhàn)項目
????????地址:https://github.com/BreakingY/simple-rtsp-client
????????支持RTP OVER UDP、RTP OVER TCP,支持H264/H265、AAC/PCMA、支持鑒權(quán)。
不需要任何依賴。
1、編譯
git clone https://github.com/BreakingY/simple-rtsp-client.gitmkdir buildcd buildcmake ..make -j
2、測試
./rtsp_client rtsp_url
????????客戶端會把收到的音視頻寫入文件,H264/H265寫入到test_out.h26x,AAC寫入到test_out.aac,PCMA寫入到test_out.pcma。