Overview
Integrating IP cameras into Agora channels allows real-time broadcasting of camera feeds for live streaming, surveillance, or interactive communication. The workflow involves converting RTSP streams from IP cameras to a compatible format and sending them to Agora's Media Gateway for ingestion into an RTC channel.
Components and Workflow
1. RTSP Stream (IP Camera Output)
- RTSP (Real-Time Streaming Protocol): Standard protocol used by IP cameras for streaming video and audio.
-
Configuration Requirements:
- Obtain the RTSP URL from the IP camera. Below is the example format.
rtsp://<username>:<password>@<camera-ip>:<port>/<path>
rtsp://<username>:<password>@<camera-ip>:<port>
- Ensure the camera supports protocols and codecs compatible with FFmpeg and Agora, such as H.264/H.265 for video and AAC for audio.
- Obtain the RTSP URL from the IP camera. Below is the example format.
2.1 OBS (Open Broadcaster Software)
- Role: OBS provides a user-friendly interface to manage, enhance, and broadcast IP camera feeds. It can accept streams from FFmpeg or directly from RTSP.
-
Steps to Configure OBS:
-
Add the Camera Feed:
- Go to Sources, click the "+" button, and select Media Source.
- Paste the RTSP URL of the IP camera.
-
Adjust Stream Settings:
- Follow Media Gateway quick start guide.
- Navigate to Settings > Stream and configure the streaming server (e.g., RTMP endpoint of Agora Media Gateway).
- Example:
rtmp://<agora-ingest-url>/<stream-key>
.
-
Start Streaming:
- Click Start Streaming to begin broadcasting the feed to Agora.
-
Add the Camera Feed:
2.2 FFmpeg (Instead of FFmpeg will add OBS or other Live Production Tool)
- Role: FFmpeg processes the RTSP stream and transcodes it into a format that the Agora Media Gateway accepts.
-
Key Features Used:
- Transcoding for compatibility.
- Stream publishing using RTMP or other supported protocols.
- Example Command (Bash):
- Replace
<username>
,<password>
,<camera-ip>
,<port>
,<path>
,<agora-ingest-url>
, and<stream-key>
with appropriate values.
3. Agora Media Gateway
-
Usage:
- Ingests external media streams into an Agora RTC channel.
-
Stream Key:
- Definition: A unique key used to identify and authenticate the external stream.
-
Obtaining the Stream Key:
- Navigate to the Media Gateway guide section.
- Generate a stream key locally or with Rest API.
-
Channel Mapping:
- Each stream key is tied to a specific Agora RTC channel.
- Users in the channel can view the external stream as a audience.
4. Agora RTC Channel
- Audience: The audience user can subscribe to the remote audio and video streams from IP Camera in real-time.
Troubleshooting and Tips
-
Common Issues:
-
Buffering or Latency: Adjust
-bufsize
and-preset
options in FFmpeg for better performance. - OBS Configuration Issues: Double-check the RTMP server URL and Stream Key.
- Codec Incompatibility: Verify the codecs (e.g., H.264, AAC) used by the IP camera.
-
Buffering or Latency: Adjust
-
Best Practices:
- Use a stable network connection for both the IP camera and the FFmpeg/OBS host.
- Regularly test components for compatibility.
- For you can enable logging in FFmpeg for detailed diagnostics:
-
Testing:
- Test individual components (RTSP, FFmpeg, OBS) before full integration.