Try Live Demo

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 in HLS

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:

Live rewind

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.

  1. Open your application properties file with your favorite editor. i.e. for LiveApp, it’s /usr/local/antmedia/webapps/LiveApp/WEB-INF/red5-web.properties
  2. Set or add the following properties in the file
    settings.hlsPlayListType=event
    settings.hlsflags=
    

    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.

  3. Save the file and restart Ant Media Server
    sudo service antmedia restart
    
  4. Send a Live Stream to Ant Media Server with WebRTC or RTMP. Let’s assume that you’re sending a live stream with stream1 id.
  5. 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 Live edge Ant Media Server DVR featureYou can click anywhere in the slider to rewind back to the live stream as below. Ant Media Server rewind HLS

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:

  1. Just use the application settings below. We just specify the settings.hlsListSize and settings.hlsTime. Let me tell what these parameters are. settings.hlsListSize is the segment list size which means that number of ts files in m3u8 file. settings.hlsTime is 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.hlsTime to 4 and settings.hlsListSize to 21600because 4*21600 = 86400 seconds and it’s 24 hours.settings.hlsPlayListType=
    settings.hlsflags=delete_segments
    settings.deleteHLSFilesOnEnded=true
    settings.hlsListSize=21600
    settings.hlsTime=4

    Don’t forget to restart the Ant Media Server with sudo service antmedia restart after you’ve changed settings in application properties file

  2. 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.settings.hlsPlayListType=event
    settings.hlsflags=
    settings.streamFetcherRestartPeriod=86400
    settings.deleteHLSFilesOnEnded=true

    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 SDKsand everything by signing up with zero upfront cost. In addition to the DVR feature, you will have access to all the features.

You can start for free now!

Categories: Tutorial

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.