มาสร้าง RTSP Stream Proxy ใช้งานกันเถอะ

ขอเล่าเหตุการณ์ที่มาของ Stream proxy server ก่อนนะ ได้ซื้อกล้อง IP Camera มาใหม่ TP-Link Tapo C200 โดยเจ้าตัวกล้อง support rtsp ซึ่งตรงกับความต้องการ ความคมชัด 1080P ราคาไม่แพงมาก ตัวกล้องจะมี rtps มาให้ 2 stream
- high: rtsp://IP Address/stream1
- low: rtsp:// IP Address/stream2
ซึ่งก็ดูเหมือนจะเพียงพอใช่ไหม แต่ๆปัญหาคือ ถ้าเราจะใช้งาน high stream มากกว่า 1 client ตัวกล้องไม่ยอมให้ใช้งาน ตัวอย่างเช่น
- client 1: สำหรับ NVR เพื่อบันทึกเหตุการณ์ต่างๆ 24 ชั่วโมง
- client 2: สำหรับ Home Assistant เพื่อทำระบบ automation แจ้งเตือน
พอมองเห็นปัญหาแล้วใช่ไหม? RTSP stream proxy server สามารถแก้ไขเรื่องนี้ได้ ยังไง?

จากรูปด้านบน proxy server จะทำหน้าสร้าง connection ให้แก่ client ต่างๆ ให้มากกว่า 1 connection
เริ่มติดตั้ง RTSP Stream Proxy
- ทำการสร้างไฟล์ config.yaml
streams:
- url: "rtsp://username:[email protected]:554/stream1"
name: "tapoc200"
- url: rtsp ของกล้อง tapo ที่เราต้องการทำ proxy
- name: ตั้งชื่อ stream name สำหรับเรียกใช้งาน
2. ติดตั้ง server ผ่านทาง docker
docker run -it -p 5554:5554 -v /path/to/your/config.yaml:/opt/rts2p/rts2p.yaml snowzach/rts2p:latest
- /path/to/your/config.yaml แก้ไขเป็น path ที่เราสร้างไฟล์ config.yaml
3. การเรียกใช้งานงาน proxy server
rtsp://192.168.x.xxx:5554/tapoc200
- 192.168.x.xxx คือ ip ของ proxy server ที่เราติดตั้งผ่านทาง docker