๋ฐ์ํ
๐ก ๋ณธ ๋ฌธ์๋ 'RTSP ์๋ฒ ํด๋ผ์ด์ธํธ ๊ตฌ์ถํ๊ธฐ(feat. rtsp-simple-server)'์ ๋ํด ์ ๋ฆฌํด๋์ ๊ธ์ ๋๋ค.
๊ฐ๋จํ RTSP ์๋ฒ๋ฅผ ๊ตฌ์ถํ์ฌ ํน์ ์์์ streamํ๊ณ ์ด๋ฅผ ์์ ํ๋ ํด๋ผ์ด์ธํธ๋ฅผ ๊ตฌ์ถํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์ ๋ฆฌํ์์ผ๋ ์ฐธ๊ณ ํ์๊ธฐ ๋ฐ๋๋๋ค.
1. Installation
1.1. Download FFmpeg:
% brew install ffmpeg
1.2. Download VLC(VLC Media Player):
% brew install --cask vlc
Error: It seems there is already an App at '/Applications/VLC.app'.
% nano ~/.bashrc
...
alias vlc='/Applications/VLC.app/Contents/MacOS/VLC'
% source ~/.bashrc
2. basic usage
2.1. Download and launch the image:
$ docker run --rm -it --network=host aler9/rtsp-simple-server
2023/04/25 12:24:35 INF MediaMTX / rtsp-simple-server v0.22.2
2023/04/25 12:24:35 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2023/04/25 12:24:35 INF [RTMP] listener opened on :1935
2023/04/25 12:24:35 INF [HLS] listener opened on :8888
2023/04/25 12:24:35 INF [WebRTC] listener opened on :8889 (HTTP)
2.2. Publish a stream. For instance, you can publish a video file with FFmpeg:
% ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream
ffmpeg version 2.8.17-0ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.1 --build-suffix=-ffmpeg --toolchain=hardened
...
2.3. Open the stream. For instance, you can open the stream with VLC:
# vlc
% vlc rtsp://localhost:8554/mystream
# GStreamer
% gst-launch-1.0 rtspsrc location=rtsp://localhost:8554/mystream name=s s. ! application/x-rtp,media=video ! decodebin ! autovideosink s. ! application/x-rtp,media=audio ! decodebin ! audioconvert ! audioresample ! autoaudiosink
# ffplay
% ffplay rtsp://localhost:8554/mystream
# FFmpeg
% ffmpeg -i rtsp://localhost:8554/mystream -c copy output.mp4
+ ์ถ๊ฐ
[Blog] VLC Media Player(GUI)๋ฅผ ์ด์ฉํ RTSP ์๋ฒ ํด๋ผ์ด์ธํธ ๊ตฌ์ถ
Video Player๋ก ์ข ์ข ์ฌ์ฉํ๋ VLC์์ ์ง์ํ๋ ๊ธฐ๋ฅ์ธ RTSP ์คํธ๋ฆฌ๋ฐ์ ์ด์ฉํ์ฌ RTSP ํด๋ผ์ด์ธํธ ๋ฐ ์๋ฒ๋ฅผ ๊ตฌ์ถํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์ค๋ช ํฉ๋๋ค.
[Blog] ์น์์ IP ์นด๋ฉ๋ผ ์คํธ๋ฆฌ๋ฐ ํ๊ธฐ
์น์์ ์นด๋ฉ๋ผ๋ฅผ ์คํธ๋ฆฌ๋ฐํ๊ธฐ ์ํ ์ฌ๋ฌ ํ๋กํ ์ฝ์ ์ ์ฉํด๋ณด๋ ์ํ์ฐฉ์ค ๊ณผ์ ์ ๋ํด ์ ๋ฆฌํด๋์ ๋ฌธ์๋ก, ๊ฒฐ๋ก ์ 'FFMPEG๋ก RTSP๋ฅผ HLS๋ก ๋ณํํ์ฌ ์น์์ ๋ฐฐํฌ' ์ ๋๋ค.
[Blog] Browser RTSP, RTMP, HLS CCTV streaming ์ด์ ์ ๋ฆฌ
์นด๋ฉ๋ผ ์์์ RTSP๋ก ํ์ถํ๋ ์ด์ , RTSP๊ฐ ์น์์ ํ์ถํ ์ ์๋ ์ด์ ๋ฑ ๋ค์ํ ์ด์์ ๋ํด ์ ๋ฆฌํด๋ ๋ฌธ์์ ๋๋ค.
- ๋ณดํต ์ค์๊ฐ ์์์ RTSP ํ๋กํ ์ฝ๋ก ์ ๊ณต๋๋ฉฐ VLC Player๋ก ํ์ถ ๊ฐ๋ฅํฉ๋๋ค.
- ์ด๋ฅผ ๋ธ๋ผ์ฐ์ ์์ ํ์ถํ๊ณ ์ถ๋ค๋ฉด RTSP ํ๋กํ ์ฝ์ HLS ํ๋กํ ์ฝ๋ก ๋ณํํด์ฃผ๋ ์์ ์ด ํ์ํ๋ฉฐ,
- HLS ํ๋กํ ์ฝ๋ก ๋ณํํ๋ ์์ ์ด ์ด๋ ค์ธ ๊ฒฝ์ฐ, WOWZA ์ ๊ฐ์ ๋ฐ์ ์์์ ์ฌ๋ฌ ํ๋กํ ์ฝ๋ก ๋ณํ(RTMP, HLS ๋ฑ) ํด์ฃผ๋ ์คํธ๋ฆฌ๋ฐ ์ํํธ์จ์ด๋ฅผ ์ฌ์ฉํด์ผํฉ๋๋ค. (์ ๋ฃ)
- ๋๋ค๋ฅธ ๋ฐฉ๋ฒ์ FFmpeg ๋ฅผ ํ์ฉํ๋ ๋ฐฉ๋ฒ์ผ๋ก ์ฐ๊ฒฐ๋ RTSP ํ๋กํ ์ฝ ์์์ ์ค์ ๋ ์๊ฐ(์ด), ํ์ผ ๊ฐ์๋งํผ .ts ํ์ผ(์์ํ์ผ)๋ก ๋ง๋ค์ด ํด๋น ํ์ผ์ stream ํ์ผ๋ก ์ ๊ณตํ ์ ์์ต๋๋ค.
์ฐธ๊ณ
- [DockerHub] rtsp-simple-server: https://hub.docker.com/r/aler9/rtsp-simple-server
- [Github] mediamtx: https://github.com/aler9/mediamtx#table-of-contents
- [Github] mediamtx: ready-to-use RTSP / RTMP server and proxy that allows to read, publish and proxy video and audio streams: https://golangrepo.com/repo/aler9-rtsp-simple-server-go-server-applications#convert-streams-to-hls
- [StackExchange] How to run VLC command in mac terminal: https://superuser.com/questions/997673/how-to-run-vlc-command-in-mac-terminal
- [Blog] VLC Media Player(GUI)๋ฅผ ์ด์ฉํ RTSP ์๋ฒ ํด๋ผ์ด์ธํธ ๊ตฌ์ถ: https://post.naver.com/viewer/postView.naver?volumeNo=29553682&memberNo=2534901
- [Blog] ์น์์ IP ์นด๋ฉ๋ผ ์คํธ๋ฆฌ๋ฐ ํ๊ธฐ: https://qodbtn.tistory.com/392
- [Blog] Browser RTSP, RTMP, HLS CCTV streaming ์ด์ ์ ๋ฆฌ: https://aljjabaegi.tistory.com/560
๋ฐ์ํ