Skip to content

Working with DVR Archive in Middleware

This article aims to assist Middleware developers in implementing video archive functionality to fulfill various user scenarios, including but not limited to:

  • Pausing live broadcast to take a break
  • Watching the current program from the beginning because they like the movie and want to start over
  • Watching yesterday's program
  • Bookmarking a favorite program to watch again in a few months

The problem addressed in this article is that the only protocol technically capable of easily implementing those scenarios is RTSP. However, RTSP has long been abandoned in favor of segment-based HTTP protocols: HLS, DASH (and a bit of MSS). None of these mainstream protocols for IPTV OTT support archive and DVR functionality out-of-the-box, hence the need for technical ingenuity to solve these tasks.

How to Best Manage Access to the Archive?

The most effective way to facilitate access to the archive is by using epg-vod for playing archived content, and using event for playing live broadcasts.

Playing Archive by EPG

For this method to work, the Middleware must maintain a precise EPG schedule. References to timestamps and time will be made throughout this section. We only consider seconds in UTC (Epoch time). Under no circumstances should local time be used, as it introduces unnecessary confusion.

When watching a program, it is recommended to store the current viewing time in the middleware database, so that upon reopening the user can choose whether to resume or to start from the beginning.

For example, when a user selects the program that aired from 1717677139 UTC to 1717679255 UTC from the archive, the following URL must be generated for the player: http://FLUSSONC-IP/STREAM_NAME/archive-1717677139-2116.m3u8?event=true

This URL allows the player to handle:

  • Seek within the program
  • Pause
  • Fast forward playback

At the end of playback, it is recommended to switch to the next program in the EPG to ensure a continuous flow of content to the viewer.

Viewing the Current Broadcast with Event Playlists

Viewing the current broadcast is technically more challenging. We recommend using event playlists, but they do not allow rewinding in native Safari, making them unsuitable for TV. In such cases you would need to write your own timeline code in JavaScript. If Safari is not critical for the operation, you can confidently use the same URLs as in epg-vod:

http://FLUSSONIC-IP/STREAM_NAME/archive-1717677139-2116.m3u8?event=true

The trick is that if the playlist's closing moment is in the future, it will be served not as VOD, but as EVENT, allowing the player to re-request it and continue playing.

After this playlist ends, you should also switch to the next one according to the EPG and continue viewing.

Using such a URL allows pausing the live stream and resuming from the same spot. It is important to note that you need to program the "live" button yourself, because during the pause the playlist might automatically switch from EVENT to VOD and close. In this case, you need to determine the next program in the EPG and jump to it.