The latest version of Ant Media Server has brought many exciting features for developers.
One of them is the DVR feature. This feature is important for clients who want to watch past videos. You can use DVR(Digital Video Recorder) feature in Video JS. It’s supported by default. Here is a step-by-step tutorial that lets you learn how to enable DVR in Video JS with HLS Streaming.
How to enable DVR and what are the use cases of DVR?
The DVR is actually required for all use cases where you need to watch and save stream history and the most well-known use case is IP Camera systems. As you know, it may be necessary to check the history from time to time for various reasons. Now, you can customize this requirement with Ant Media Server.
Now we will explain step-by-step guide how the DVR can be activated in Ant Media Server:
Ant Media Server deletes the obsolete HLS segments by default. So we need to make Ant Media Server keep every HLS segment in the list. In order to use live rewind in streams.
- Open your application properties file with your favorite editor. i.e. for LiveApp, it’s
- Set or add the following properties in the file
The default HLS flag is delete_segments so we just keep it empty. For this configuration, user can seek back to anytime since the broadcast starts.
- Save the file and restart Ant Media Server
sudo service antmedia restart
- Send a Live Stream to Ant Media Server with WebRTC or RTMP. Let’s assume that you’re sending a live stream with
- Open the HLS player in your browser.
https://YOUR_SERVER:5443/LiveApp/play.html?id=stream1&playOrder=hlsYou should see the slider bar in the player as shown below. It’s by default playing the
Liveedge You can click anywhere in the slider to rewind back to the live stream as below.
How to specify the rewind window range
According to your requirements, you may let your users seek back to 1 hour earlier or maybe 24 hours in HLS. You have 2 options to specify the rewind range. Let us explain step by step:
- Just use the application settings below. We just specify the
settings.hlsTime. Let me tell what these parameters are.
settings.hlsListSizeis the segment list size which means that number of ts files in m3u8 file.
settings.hlsTimeis the segment duration which is the duration of each ts files. So if we need 24 hours window to seek back. We can set the
settings.hlsTimeto 4 and
21600because 4*21600 = 86400 seconds and it’s 24 hours.
Don’t forget to restart the Ant Media Server with
sudo service antmedia restartafter you’ve changed settings in application properties file
- If you’re using IP Camera or stream source, you can use this method. Just use the settings below and set the application properties as follows.
These settings just restarts the stream source every 24 hours(86400) and clears the ts and m3u8 files in every restart. Don’t forget to restart the service after you’ve changed settings in application properties file
Use Ant Media Server for free for 100 hours every month
You don’t need to pay anything in advance. Just get started and only pay for what you use. Ant Media provides 100 hours of free usage every month and you’ll have Ant Media Server with all WebRTC SDKs, and everything by signing up with zero upfront cost. In addition to the DVR feature, you will have access to all the features.