RTSP to WebRTC: IP Camera Streaming for Real-Time Surveillance (Update)

April 27, 2022 by
A real-time surveillance control room where IP camera streams are being monitored.
 

The demand for real-time video surveillance has exploded in recent years, with the market expected to reach a whopping $74.6 billion by 2025. Surveillance streaming has evolved beyond traditional CCTV cameras and surveillance control rooms to leverage artificial intelligence (AI). This allows for faster data processing, more accurate predictions of what will happen next in time-sensitive situations, and delivery of real-time video to decision-makers in remote locations.

New features and capabilities have shifted the security landscape across a variety of sectors. Technologies like facial recognition AI, which allows IP cameras to capture an image from a significant distance and run it against a database at lightning-fast speed, are transforming surveillance across every vertical.

Such data is critical in emergency situations where every second counts toward enabling a response from law enforcement and first responders. As a result, real-time crime centers across the United States (like this one in Denver, Colorado) have been created to aggregate and analyze incoming streams using AI capabilities like facial recognition, license plate readers, and gunshot detection. But the use of this technology doesn’t stop there.

Hazardous work environments, military operations, and even healthcare settings can also benefit from advancements in surveillance. One such example is AngelEye Health, which uses Wowza to deliver around-the-clock patient monitoring to parents with newborns in the NICU. Real-time surveillance can also serve as evidence in court cases, provide peace of mind for homeowners, and be instrumental in wildfire detection.

 

Use cases leveraging real-time surveillance include:

  • Industrial robots
  • Mining operations
  • Healthcare monitoring
  • Law enforcement-crowd control
  • Natural disaster emergencies
  • Active-shooter situations
  • First responder video calls (911)
  • Courtroom/legal evidence
  • Workplace safety
 
Police drone used for public safety surveillance.
 

From sophisticated drones to camera-equipped robots, security capabilities that once only existed in sci-fi films are here and growing at a rapid speed. But, instead of it being a disturbing concept, innovations in surveillance technology can increase our level of comfort by saving lives, reducing security threats, preventing industrial catastrophes, and sparing businesses from millions of dollars in loss.

 

RTSP to WebRTC: A Proven Surveillance Workflow

Most IP cameras use Real-Time Streaming Protocol (RTSP) by default, which means the streams must be repackaged into a more playback-friendly protocol like HTTP Live Streaming (HLS) for viewing. Unfortunately, this can result in up to 20 seconds of latency, which is an unacceptable amount of delay in critical surveillance use cases.

A proven workaround for this is to use Web Real-Time Communications (WebRTC) for video delivery, which is compatible with most browsers and maintains sub-second delivery. For this reason, the ability to restream RTSP feeds from IP cameras for real-time playback via WebRTC has been a surveillance and security gamechanger.

 

RTSP to WebRTC in Wowza Video

Wowza Video can accelerate your surveillance use case by ingesting your IP camera stream as RTSP and repackaging it into WebRTC with sub-second latency.

The configuration is simple.

  • Create a live stream.
  • Publish the stream using the WebRTC hosted publish page.
  • Provide the WebRTC hosted playback page URL to your viewers.

Read on for the full tutorial:

 

A. Create a Live Stream Using an RTSP-Based Encoder:

1. Sign in to Wowza Video.


2. Click the Live Streams menu, and then click Add Live Stream.

 
Screenshot of the Add Live Stream button in Wowza Streaming Cloud.
 

 3. On the Live Stream Setup page, enter a Live Stream Name, choose a Broadcast Location, and then click Next.

For this example, our Stream Name will be Wowza HQ2.

  • The Live Stream Name, which is required, should be short and descriptive.  
  • The Broadcast Location is where Wowza Video transcodes your stream. By default, the Broadcast Location is set to your browser’s time zone. Choose a Broadcast Location that’s as close as possible to the video source and supports the features you want to use.

4. On the Video Source and Transcoder Settings page, if you see your specific camera type listed, click that. If not, go ahead and select Other RTSP as the camera or encoder you want to use to connect to Wowza Video.

 
Other RTSP in the drop down menu
 

 5. For Live Stream Type, select Adaptive bitratePassthrough isn’t available for WebRTC in the live stream workflow.

Although WebRTC doesn’t support adaptive bitrate streaming, this will allow the transcoder to create an adaptive bitrate HLS stream as well should you need to reach a larger audience.

6. Specify how the encoder will communicate with Wowza Video: select Pull Stream

For pull streams, enter the encoder’s Source URL. See the encoder/camera user guide for information about its URL. The hostname or IP address in the URL must be publicly accessible. If authentication information, such as username and password, is included in the source URL, it can only contain alphanumeric, period (.), underscore (_), and hyphen (-) characters. 

 

NOTE: By default, Wowza Video uses TCP port 554 for RTSP streaming. If you don’t use the default port, be sure to indicate that in the source URL.

7. Select Prioritize latency to create an HLS stream with the lowest latency possible. 

Wowza Video will provide you with both a WebRTC and HLS playback URL.

8. Specify the Aspect Ratio. Note: For WebRTC, we recommend keeping the default Aspect Ratio of 1280 x 720.

9. Click Next for the next three pages leaving all settings as the default and click Finish.

 

B. Modify the Codecs for WebRTC Playback

For WebRTC playback in Wowza Video, you will need to transcode your RTSP stream to the following codecs:

Transcoder Settings:

1. Select Transcoders from the Advanced column in the left navigation pane.

 
Transcoders option under the Advanced menu

 

2. Click on the transcoder in the list that is the same name as your stream.

3. When that page opens, click on Outputs & Targets.

 
'Outputs and Targets' button in Wowza Streaming Cloud.

4. Locate the Passthrough transcoder (usually at the top) and then click on the symbol for Copy. See the orange arrow in image below. 

 
Screenshot showing where to located the passthrough transcoder and copy symbol in Wowza Streaming Cloud.
 

5. On the next page, click on H.264 as the video codec and Opus as the audio codec. Click Copy

6. Click Direct Playback URLs in the nav.

NOTE: On this page, you will see a list of the protocols your RTSP stream has been transmuxed into. You will only be charged for egress if any if those playback URLs are used.

(Egress is traffic that leaves Wowza Video for Wowza CDN and custom stream targets.)

7. The default viewer limit for WebRTC playback is set to 10, but you can click edit and adjust that number with a maximum of 300.

 
Screenshot showing the default viewer limit for WebRTC playback
 

8. Click on the + symbol next to the WebRTC protocol and copy the last link in the list. It will match the resolution you selected when setting up the stream. In this case, we selected 1080p for the aspect ratio and you will see that for the last link. 

Copy that link and we will paste it in the next step when we configure our WebRTC playback page.

 
Screenshot showing how to copy the WebRTC playback URL for your live stream.
 

 C. Configure the Hosted WebRTC Playback Page:

Wowza Video provides a hosted WebRTC playback page for your convenience.

1. Open wowza.com/webrtc/play.

2. Click Settings in the upper right corner.

3. Here you will paste the WebRTC link from above in the first field: SDP URL.

4. The SDP URL contains the Application Name and Stream Name information that you will need to copy and paste into the fields.

For Application Name, enter the characters just after webrtc-session.json.

In this example application, you will see it circled in orange.

 
Screenshot showing how to identify the application name and stream name within the SDP URL.
 

5. For Stream Name, enter the characters at the end of the SDP URL (blue arrow). 

 
Screenshot showing the SDP URL, Application Name, and Stream Name.
 

NOTE: Your URL may display as entrypoint.cloud.wowza.com/webrtc-session.ison or entrypoint.video.wowza.com/webrtc-session.ison. Either one is fine.

 

D. Start the Stream in the Wowza Video Manager:

1. To finish up, return to the Wowza Video dashboard.

2. In the left nav, click Available Streams and click on the name of your stream. In this example, we had named ours Wowza HQ2.

 
Live stream dropdown menu in Wowza Streaming Cloud.
 

3. When the overview page for your stream appears, click the green button that says Start Live Stream

 
Start Live Stream in Wowza Video
 

 4. Once the Live Stream has started, return to your WebRTC playback page and click Play.

 
Screenshot showing the WebRTC playback page for Wowza Streaming Cloud.
 

Summary:

Congratulations! Your WebRTC stream will begin on the hosted playback page with a latency averaging sub-500 milliseconds.

If you’d like to deliver your RTSP stream over both WebRTC and HLS, simply return to the Wowza Video dashboard and click on the HLS Hosted Page URL.

 
Screenshot showing how to locate the Hosted Page URL for HLS delivery.
 

NOTE: This is the HLS playback page and is different than the WebRTC playback page we configured at wowza.com/webrtc/play.

You may choose to use the WebRTC playback page only, but should you use HLS hosted page as well, you’ll notice your HLS playback will average about 9- 12 seconds behind your WebRTC stream. This is because HLS playback typically has higher latency due to default buffer requirements.

When it comes to surveillance, most IP cameras send out an RTSP stream that is low latency but can only be viewed with specific software. With Wowza Video, however, it’s easy to convert your RTSP stream to WebRTC for real-time playback in a browser.

 

About Rose Power

Rose Power is the developer community manager for Wowza Media Systems. Passionate about building relationships with the dev community, Rose strives to deliver quality resources for a positive user experience built on trust. When not working, she can be found… View more