Try Live Demo

IP camera streaming solutions are used for streaming needs from medical devices to smart traffic infrastructure, from event broadcasts to live documentaries and of course surveillance. Security and low latency are one of the most important criteria for organizations in live video surveillance and other IP camera streaming space.

In this blog post, we will cover

  • IP cameras
  • IP camera streaming uses cases
  • IP camera streaming protocols (to understand which protocol you need)
  • IP camera streaming without NVRs
  • Benefits of IP camera streaming
  • How to set up an IP camera and record streams
  • Embedded WebRTC SDK for IP camera manufacturers

What is an IP Camera?

what is ip camera?

An IP camera, or Internet protocol camera, is a type of digital security camera that receives and sends video streams via an IP network. They are commonly used for surveillance. Unlike analog closed-circuit television cameras (CCTV), IP cameras do not require a local recording device, only a local network. IP cameras connect to a network in the same way that phones and computers connect. 

IP Camera Streaming Use Cases

ip camera streaming use cases

There are some use cases where the use of an IP camera streaming is mandatory and it works quite well. Network cameras for live streaming are particularly suitable for 24/7 streams, broadcasts from inaccessible locations, and shorter events that do not require the physical presence of a cameraman, such as conferences, trade shows, and conferences. Other use cases include:

  • Nature shots: IP camera streaming is a great solution for broadcasting nature life. Some of the reasons for this are that it is easy to use, and is resistant to the harsh conditions of nature. For this reason, it is quite easy to present the magnificent events of nature to the audience.
  • Performances: Whether you want to shoot a concert or theatrical performance, IP cameras can provide dynamic angles that will engage your audience.
  • Ceremony: IP cameras don’t need operators to move because they can be fixed. This allows IP cameras to be placed in perfect positions to capture great angles.
  • Surveillance: Whether you’re looking to add security to a bank, a construction site, or your home, IP cameras can be a great option to provide that constant supply of peace of mind.

IP camera streaming generally used “RTMP to HLS” and “RTSP to HLS” setups. However, these setups were causing 10-12 second delays. Ant Media Server has developed different solutions for different latency needs. Now let’s see how much latency different protocols provide and which is the most suitable for your IP camera streaming needs.

RTMP and RTSP can be used to capture streams from the IP camera. Let’s see how the RTMP protocol works.

IP Camera Streaming with RTMP

RTMP can be used to capture streams from the camera in IP camera streaming.

How Does RTMP Work?

RTMP streaming provides a stable connection between the player client and the server, allowing the protocol to act as a channel and quickly move video data to the viewer’s device.

Since RTMP uses the Transmission Control Protocol (TCP), it uses a three-way handshake when moving data. Here’s the method: the initiator asks the server to start a connection (first handshake). When the server responds (second handshake), the initiator acknowledges it (third handshake) and a reliable connection is established.

It has two use cases:

  1. First-mile delivery

It is the part where an RTMP stream is used to pull the video from IP cameras to a server.

  1. Last-mile delivery

In this part, the RTMP live streaming protocol is used to send data from a server to a video device using a Flash player.

As video streaming with RTMP is no longer supported by all devices, RTMP streaming is not used for last-mile delivery and has been replaced by HTML5 streaming protocols. However, the most efficient way is to use HTML5 streaming protocols for both cases.

RTMP Technical Specifications

  • Audio Codecs: AAC, AAC-LC, HE-AAC+ v1 & v2, MP3, Speex
  • Video Codecs: H.264, VP8, VP6, Sorenson Spark®, Screen Video v1 & v2
  • Playback Compatibility: Not widely supported anymore
    • Limited to Flash Player, Adobe AIR, RTMP-compatible players
    • No longer accepted by iOS, Android, most browsers, and most embeddable players
  • Benefits: Low latency and minimal buffering
  • Drawbacks: Not optimized for quality of experience or scalability
  • Latency: 5 seconds
  • Variant Formats: RTMPT (tunneled through HTTP), RTMPE (encrypted), RTMPTE (tunneled and encrypted), RTMPS (encrypted over SSL), RTMFP (layered over UDP instead of TCP)

IP Camera Streaming with RTSP

RTSP is the most used protocol in IP camera streaming. Most of the IP cameras are released with RTSP support.

How Does RTSP Work?

RTSP is conceptually similar to HTTP in function and was easily compatible with existing HTTP networks when it was first developed.

It was described as a “network remote control” for media servers. It was designed to control the streams without downloading any files. When a video stream is started, a device using the protocol sends an RTSP request to the media server that initiates the setup process.

RTSP also supports several control request operations (also known as “commands”) such as play, pause, setup, etc. (I will give you some example requests in the following section.) The first request must also inform the client about the available options via the “OPTIONS” command. After that, a user can watch, or turn off the stream. RTSP maintains an end-to-end connection with TCP and achieves a high throughput over this stable connection without requiring any local download or caching.

The protocol does not support content encryption or retransmission of lost packets, as RTSP is connected to a dedicated server for streaming and relies on RTP to transmit real media. These limitations along with scaling problems led to a drop in overall RTSP usage.

RTSP Requests

When negotiating and controlling media streams, RTSP usually uses the following commands usually sent from the client to the server:

  • Options: This request determines what other types of requests the media server will accept.
  • Describe: A description request identifies the URL and type of data.
  • Announce: The announce method describes the presentation when sent from the client to the server and updates the description when sent from server to client.
  • Setup: Setup requests specify how a media stream must be transported before a play request is sent.
  • Play: A play request starts the media transmission by telling the server to start sending the data.
  • Pause: Pause requests temporarily halt the stream delivery.
  • Record: A record request initiates a media recording.
  • Teardown: This request terminates the session entirely and stops all media streams.
  • Redirect: Redirect requests inform the client that it must connect to another server by providing a new URL for the client to issue requests to.

There are also other types of RTSP requests such as ‘get parameter,’ ‘set parameter,’ and ’embedded (interleaved) binary data. You can find more information here.

RTSP Technical Specifications

  • Audio Codecs: AAC, AAC-LC, HE-AAC+ v1 & v2, MP3, Speex, Opus, Vorbis
  • Video Codecs: H.265 (preview), H.264, VP9, VP8
  • Playback Compatibility: Not widely supported and rarely used for playback (Quicktime Player and other RTSP/RTP-compliant players, VideoLAN VLC media player, 3Gpp-compatible mobile devices)
  • Benefits: Low-latency and ubiquitous in IP cameras
  • Drawbacks: Not optimized for quality of experience and scalability
  • Latency: 2 seconds
  • Variant Formats: The entire stack of RTP, RTCP (Real-Time Control Protocol), and RTSP is often referred to as RTSP

IP Camera Streaming with HLS (10-12 second latency)

HLS stands for HTTP Live Streaming. It is an adaptive HTTP-based protocol used for transporting video and audio data from media servers to the end user’s device.

HLS was created by Apple in 2009. Apple announced the HLS at about the same time as the legendary device iPhone 3. Earlier generations of iPhone 3 had live streaming playback problems, and Apple wanted to fix this problem with HLS.

IP camera streaming often used “RTMP to HLS” and “RTSP to HLS” setups. But these setups provide a delay of at least 10-12 seconds.  With the increasing need for low latency in live streaming, new protocols are being used for IP camera streaming.

Features of HLS

  • Fast forward and rewind
  • Alternate audio and video
  • Fallback alternatives
  • Timed metadata
  • Content protection

HLS Technical Specifications

  • Audio Codecs: AAC-LC, HE-AAC+ v1 & v2, xHE-AAC, Apple Lossless, FLAC
  • Video Codecs: H.265, H.264
  • Playback Compatibility: It was created for iOS devices. But now all Google Chrome browsers; Android, Linux, Microsoft, and macOS devices; several set-top boxes, smart TVs, and other players support HLS. It is now a universal protocol.
  • Benefits: Supports adaptive bitrate, reliable, and widely supported.
  • Drawbacks: Video quality and viewer experience are prioritized over latency.
  • Latency: HLS allows us to have 10-12 second latency

Low Latency IP Camera Streaming with CMAF/DASH (3-5 second latency)

The Common Media Application Format (CMAF) is an extensible format for the encoding and packaging of segmented media objects for delivery and decoding on end-user devices in adaptive media streamingCMAF is basically a new format to simplify the delivery of HTTP-based streaming media. It is an emerging standard to help reduce cost and complexity and reduce latency by providing around 3-5 secs latency in streaming. CMAF simplifies the delivery of media to playback devices by working with both the HLS and DASH protocols to package data under a uniform transport container file.

You can use CMAF to play your IP camera streams in 3-5 secs latency (RTSP to CMAF or RTMP to CMAF). In some usage scenarios, a 3-5 seconds delay may be sufficient (definitely much better than 10-12 seconds). So, CMAF is a good option for IP camera streaming.

Advantages of CMAF

CMAF streaming technology is one of the easiest ways to reduce streaming latency and complexity of IP camera streaming. CMAF helps us with;

  • Cutting costs 
  • Minimizing workflow complexity 
  • Reducing latency 

Real-time IP Camera Streaming with WebRTC (0.5-second latency)

ip camera streaming with webrtc

 

WebRTC stands for web real-time communications. It is a very exciting, powerful, and highly disruptive cutting-edge technology and streaming protocol.

WebRTC is HTML5 compatible and you can use it to add real-time media communications directly between browsers and devices. And you can do that without the need for any prerequisite of plugins to be installed in the browser. WebRTC is progressively becoming supported by all major modern browser vendors including Safari, Google Chrome, Firefox, Opera, and others.

Thanks to WebRTC you can embed the real-time video directly into your browser-based solution to create an engaging and interactive streaming experience for your audience without worrying about latency. WebRTC video streaming is just changing the way of engagement in the new normal.

WebRTC Features

RTSP to WebRTC: Real-Time Surveillance Solution

real time video surveillance

Most IP cameras use Real-Time Streaming Protocol (RTSP) by default. HLS is generally used for playback. However, this causes a delay of 10-12 seconds. For some usage scenarios, this delay may not be a problem, but in some cases this delay is unacceptable.

Real-time surveillance is not possible with this setup (RTSP to HLS or RTMP to HLS). However, it is possible to play RTSP broadcasts with WebRTC in real-time (RTSP to WebRTC or RTMP to WebRTC). For this reason, the ability to stream RTSP broadcasts from IP cameras for real-time playback via WebRTC has been a surveillance and security game-changer.

It is worth mentioning again that real-time IP camera streaming is only possible with WebRTC.

RTSP to WebRTC with Ant Media Server

Ant Media Server can accelerate your surveillance use case by ingesting your IP camera stream using RTSP and repackaging it into WebRTC with 0.5 seconds latency.

The configuration is simple.

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

IP Camera Streaming without NVRs

Some IP cameras require the support of a central network video recorder (NVR) to handle the recording, video, and alarm management. Ant Media’s destructive approach changes this definition because it is using normal server hardware and the support cost is relatively low compared to NVR. Also if NVR has a tech problem, it is a big thing but Ant Media Server Case is pretty practical by changing an OEM part.

Another important part is that it is quite difficult to scale IP camera numbers with NVR. They do have in general 8,16,24,32 channels and they are limited with these numbers. With Ant Media Server we are proportionally supporting any number of IP cameras with a server hardware upgrade, so it is very easy to scale IP camera number

Benefits of IP Camera Streaming

  1. Affordable Live Stream
    Owning an IP camera with a PTZ function costs much less than a videographer using a camera. Remote camera operators can take advantage of the PTZ functionality of multiple IP cameras in real-time and switch between them to create a professional live stream. A great broadcast experience can be offered with a single operator.
  1. Simplified Video Streaming
    Video streaming is complex due to multiple protocols, codecs, playback devices, and technical difficulties. Using an IP camera simplifies your streaming workflow by combining camera and encoder. This eliminates the need for a separate encoder and reduces the hardware involved in your workflow. Ant Media Server makes it even easier.
  1. Feature-Rich Functionality
    With Ant Media Server, you can easily record broadcasts, recognize faces and objects, and even make more special additions with the plugin architecture.
  1. Reliable and Quality Delivery
    Ant Media Server transcodes live streams from your IP camera, providing adaptive bitrate (ABR) delivery to any device, anywhere. With ABR streaming, Ant Media Server sends the highest quality broadcast to each viewer’s device according to the network status. In this way, a unique experience is offered without buffering.
  2. Real-time streaming
    In some cases, a real-time delay is needed. In such usage scenarios, you can offer the real-time broadcasting experience to the audience with Ant Media Server.
  3. Security at Every Step of the Workflow
    Security has never been more critical in every area we leave our mark on, and the need to protect streaming audio and video content is one of them. Ant Media Server provides security features for every part of streaming. You can encrypt incoming and outgoing streams, require password authentication, limit who can stream to your server, restrict playback to specific IP addresses, and much more.

IP Samera Streaming with Ant Media Server

You can make your IP Cameras web browser compatible with Ant Media Server. You can embed ONVIF IP camera streams into your websites and mobile applications.

You can watch the IP Camera with ultra-low latency and utilize PTZ(Pan, Tilt, Zoom) functions of the ONVIF interface. You can record your IP Camera stream on 7/24. Access, view, and manage your recordings at any time via easy to use dashboard.

With powerful REST and JavaScript API, you can do anything on Ant Media Server programmatically. If you need integration for your IP camera streaming application, REST and JavaScript API make it easy for you. In addition, there are native Android, iOS, Flutter, React Native, and Unity WebRTC SDKs as well for your mobile applications.

You can capture broadcasts from IP cameras with RTSP and RTMP and watch them with HLS (10-12 seconds latency), CMAF/DASH(3-5 seconds latency), and WebRTC(0.5-second latency), all with just a few clicks.

How to Stream Using an IP Camera with Ant Media Server

Ant Media Server Users can pull IP camera streams easily on the management panel. In other words, you don’t need to write any commands or use a terminal to be able to restream sources. IP camera streaming is made easy with Ant Media Server. 🙂

For IP camera restreaming, the camera should support the ONVIF standard. ONVIF makes it easy to manage IP cameras. All CRUD and PTZ operations are based on well-defined SOAP messages.

onvif for ip camera streaming

Let’s have a look at how to pull a stream from an IP camera.

Adding an IP Camera

  • Go to the management panel, Select LiveApp from applications, then click on New Live Stream and select IP Camera.
    ant media server dashboard for ip camera streaming
  • Fill in the camera name, camera username, and camera password. You should add the ONVIF URL of the IP camera. Generally, it is in the following format: IP-ADDRESS-OF-IPCAMERA:8080. If you don’t know the ONVIF URL, you can use “auto-discovery” feature. If the IP camera and the server are in the same subnet, the Ant Media server automatically can discover them. The screenshot of the auto-discovery result is shown below.
    adding ip camera to ant media server

Watching IP Cameras

If IP cameras are reachable and configured correctly, Ant Media Server adds their streams as a live stream and starts to pull streams from them. You can see its status on the management panel. To watch the stream, click the Play button under Actions.

watching ip cameras

Recording IP Camera Streams

The Ant Media Server can save IP camera streams in MP4 format. It record streams with defined periods such as one-hour or ten hours interval. You can see these recorded files on the VOD tab in the management panel.

Recording IP camera streams

Restreaming External Sources

Ant Media Server (AMS) can operate with different streaming flows. As well as accepting and creating streaming media, it also has the capability to pull live streams from external sources, such as live TV streams, IP camera streams, or other forms of live streams (RTSP, HLS, TS, FLV, etc.).

Restreaming external sources

In order to restream from an external source, follow those steps:

  • First, log in to the management panel. Click on New Live Stream > Stream Source. Define stream name and URL.
  • AMS starts to pull streams.
  • As the stream starts to pull, you can watch it from the AMS panel.

Ant Media’s Embedded WebRTC SDK for IP Camera Manufacturers

Ant Media server can stream from IP cameras, and this solution is for IP camera manufacturers. If you just want to use peer to peer connection between an IP camera and a web browser, Ant Media can also provide a solution for this case as well.

Embedded WebRTC SDK can run on both ARM and x86 processors. IP cameras generally have a built-in RTSP URL. You can embed Native WebRTC SDK into your IP camera and the SDK fetches the RTSP stream and then forward the RTSP stream to the other peer via WebRTC.

Native SDK does not transcode the RTSP stream. It just fetches the stream and forwards it to the WebRTC stack. Hence, it does not need a lot of CPU resources. Also, there is very minimal latency.

Ant Media Server Embedded WebRTC SDK

WebRTC IP Camera and Browser (P2P)

1. WebRTC IP camera and browser (P2P)

Signaling of WebRTC SDK is compatible with Ant Media Server. You need to use Ant Media Server as a signaling server in order to have peer to peer connection between a web browser and your IP camera.

2. How to use the Embedded SDK

There is only one method you need to call in your application. Here is the sample code.

int main(int argc, char* argv[]) {
	rtc::InitializeSSL();
	signalingThread = rtc::Thread::Current();
	startWebSocket(“ws://Your_Ant_Media_Server_Address:5080/WebRTCAppEE/websocket”,
	“rtsp://127.0.0.1:6554/stream1”, “stream1”);
	rtc::CleanupSSL();
	return 0;
}

As you can see, the critical method is startWebSocket method, which has three parameters

    • The first parameter is the WebSocket URL of the Ant Media Server
    • The second parameter is the internal RTSP URL of the IP camera
    • The third parameter is the stream id that will be published. After you run this application, visit  http://Your_Ant_Media_Server_Address:5080/WebRTCAppEE/peer.html and write the stream id that you’ve used in your code (stream1 in the sample code), and click the JoinButton. Now you can watch the IP camera stream on your browser.

We hope this detailed blog post has answered all your questions about IP camera streaming. If you are an IP camera manufacturer, do not forget to contact us for detailed information about Embedded WebRTC SDK. You can contact us here.

Useful links for streaming heroes:

How to enable SSL?
Developer Community

Check out some of our success stories

WebRTC Servers
Free RTMP server installation
WebRTC Guide
RTMP Guide
RTSP Guide
HLS Guide
CMAF Guide
SRT Guide
Building WebRTC Mobile App
Android SDK
iOS SDK
Flutter SDK
React Native SDK
Unity SDK
WebRTC to HLS & DASH  
IP Camera Streaming Made Easy with Ant Media Server
Ultra-Low Latency Streaming Uses Cases

 

Categories: Tutorial

Hamit Demir

As a B2B tech marketer, Hamit Demir works as a solution expert at Ant Media. He has experience in SEO, Demand Generation, Paid Search & Paid Social, and Content Marketing. He spends his free time learning new things. He loves to talk about streaming and especially WebRTC.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.