Video Streaming Server With Multi-Protocol,Robust And Rich API
Location:Index Page  >  Document  >  Record & NVR

Here, we will introduce the recording and NVR of the Ti Top Streamer

1. First, there are recording related settings on the web console pannel of Ti Top Streamer. At present, it is the setting for an application, that is, the setting takes effect globally within an application.

The UI of this setting is shown in the following figure:

Record

You can easily understand these setting parameters at a glance, which are very simple: whether to record, the storage path of the recording file, the duration of each recording file (default 1000 milliseconds), and the maximum kept period of the recording file (after which it will be automatically deleted).

Here,It should be noted that in the storage root directory shown in the above figure, Ti Top Streamer will continue to create several layers of subdirectories. The first and second level subdirectories are the names of Application and Stream, respectively. Going further down to the subdirectories, I won't go into much detail here. Just give it a try and you'll know.

In addition, the files generated by recording are TS files. The purpose is to facilitate HLS NVR playback.

2. Secondly, how to use the generated files for recording? Here are two application scenarios we support:

1) export to mp4 file:

We provide the Rest API, and once you submit a request through the interface, Ti Top Streamer can generate the required mp4 file for you based on the parameters in the request. The following are examples of interface calls:

http://x.x.x.x:port/v1/nvr/convert2mp4
		
Here, let's give a brief explanation:

The request use the post method, and the port is the port of the Rest service. The message body passed is in JSON format, and the parameters include the following:

1) app_name: It is the name of an application, e.g. live

2) stream_name: It is the name of a steam, e.g. myStream

3) start_time: It is a unix timestamp, accurate to milliseconds (absolute time), representing the start time.

4) end_time: It is a unix timestamp, accurate to milliseconds (absolute time), representing the end time.

5) duration: It is in milliseconds, representing the duration.

6) file_name: The file name for the recorded file is optional. If this parameter is not present, we will generate the mp4 file using the default naming convention.

Note:You can only choose one between end_time and duration. If two parameters appear simultaneously, end_time shall prevail.

Here is an example for the message body:
{
"app_name":"live",
"stream_name":"s6",
"start_time":1682648690000,
"end_time":1682648724000,
"file_name":"982FADE09C884D84A874E10034B85FAC_20230613164615038.mp4"
}
		

Note:Exporting MP4 files from recorded TS segment files takes a certain amount of time, and the longer the video duration, the longer the export time required. So, once Ti Top Streamer receives this request and starts processing the export of mp4 files, it will immediately respond to this request. That is to say, the request logic is asynchronous. The final generated MP4 file will be generated in the root directory of the recording file (the recording file storage path you set on the web console pannel). After our testing, it was found that a typical 10 minute MP4 file takes approximately 5 seconds to generate (actual situation, you need to conduct actual testing based on specific server performance to determine).


2. HLS NVR playback

Recorded files can be played through HLS. Let's take live applications and myStream streams as examples to introduce the URL format of HLS NVR playback streams:

http://x.x.x.x:port/live/myStream/playlist.m3u8&start_time=1661569392519&end_time=1661569452519
#or
http://x.x.x.x:port/live/myStream/playlist.m3u8&start_time=1661569392519&duration=60000
		
The parameters in the URL above, Both "start_time" and "end_time" are Unix timestamp, accurate to milliseconds (absolute time), representing the start and end times. "duration" is a video duration accurate to milliseconds.