Overview

In individual recording mode, Agora Cloud Recording generates M3U8 index files and TS/WebM slice files. To process the recorded files, such as merging the audio and video files, or synchronizing the playback with other stream files, you need to know the naming conventions of the recorded files, how to parse the information in the M3U8 file, and when slicing occurs.

Naming conventions

In individual recording mode, the naming conventions are as follows:

M3U8 file: <sid>_<cname>__uid_s_<uid>__uid_e_<type>.m3u8
TS file: <sid>_<cname>__uid_s_<uid>__uid_e_<type>_utc.ts
WebM file: <sid>_<cname>__uid_s_<uid>__uid_e_<type>_utc.webm

Where:

  • <sid>: Recording ID
  • <cname>: Channel name
  • <uid>: User ID
  • <type>: File type, audio or video
  • <utc>: The UTC time when the slice file starts. The time zone is UTC+0, and the timestamp consists of the year, month, day, hour, minute, second, and millisecond. When utc is 20190611073246073, for example, the slice file starts at 07:32:46.073 a.m., June 11, 2019.

In the file name sid713476478245_cnameagora__uid_s_123__uid_e_video_20190920125142485.ts, sid713476478245 is the recording ID, cnameagora is the channel name, 123 is the user ID, and the start time of the recording is 12:51:42.485 a.m., September 20, 2019.

Naming conventions of the transferred files

If Agora Cloud Recording fails to upload the recorded files to the third-party cloud storage, it will transfer the files to the third-party cloud storage from the Agora Cloud Backup. In order not to overwrite the latest files, the M3U8 file will have a suffix: <sid>_<cname>__uid_s_<uid>__uid_e_<type>_<tick>_<index>.m3u8. For example, in the file name sid713476478245_cnameagora__uid_s_123__uid_e_video_22194679897_3.m3u8, 22194679897 is the number of ticks from when the system starts to when the index file is generated, 3 is the index of the M3U8 file, meaning that the file is the third M3U8 file snapshot updated in the recording instance. The naming conventions of other types of transferred files remain the same.

M3U8 fIle

The M3U8 file contains the file names of several slice files and descriptive symbols. The M3U8 file generated by Agora Cloud Recording has three descriptive symbols:

  • #EXT-X-AGORA-TRACK-EVENT:EVENT=<event>,TRACK_TYPE=<type>,TIME=<utc>: The first slice file after a stream starts or restarts after an interruption has this descriptive symbol, which describes the state of the stream.
    • EVENT: Name of the event. Currently, EVENT can only be START, which means that the stream has started or restarted after an interruption.
    • TRACK_TYPE: The content of the slice file, AUDIO or VIDEO.
    • TIME: Time when the state of the stream changes. TIME is in UTC and the time zone is UTC+0.
  • #EXT-X-AGORA-ROTATE:WIDTH=<width>,HEIGHT=<height>,ROTATE=<rotate>,TIME=<utc>: The first slice file after a video rotates has this descriptive symbol, which describes the details of the rotation. A slice file may have several such symbols.
    • WIDTH: Width of the video.
    • HEIGHT: Height of the video.
    • ROTATE: The degrees by which the video rotates anticlockwise. ROTATE can only be 0, 90, 180, or 270.
    • TIME: The time when the video rotates. TIME is in UTC and the time zone is UTC+0.
  • #EXTINF:<length>: Length of the slice file in seconds.

For example:

#EXT-X-AGORA-ROTATE:WIDTH=640,HEIGHT=480,ROTATE=90,TIME=20190920125142485
#EXT-X-AGORA-TRACK-EVENT:EVENT=START,TRACK_TYPE=VIDEO,TIME=20190920125142485
#EXTINF:6.332000
sid713476478245_cnameagora__uid_s_123__uid_e_video_20190920125142485.ts

The sample M3U8 file above contains the file name of a TS file and three descriptive symbols, which indicates that the TS file is the first slice file after the video stream starts or restarts after an interruption, the video rotates by 90 degrees anticlockwise, and the TS file lasts for 6.332 seconds.

Slicing

Video file slicing

Slicing occurs when any of the following conditions is met:

  • When an I frame appears and the slice file reaches 15 seconds.
  • The codec changes.
  • The width or height of the video changes.
  • The video stream is interrupted.
  • When you set the browser to use H.264 codec for encoding, forced slicing occurs when the slice file reaches 5.5 minutes, or the file size is over 50 MB. After forced slicing, the first frame of the new slice file might not be an I frame, in which case the slice file cannot be decoded and played directly. For example, in the communication channel, sometimes only one I frame may appear in several hours. In such case, the first frame of the new slice file is probably not an I frame.

When you set the browser to use VP8 codec, Agora Cloud Recording will not force slicing the file.

Audio file slicing

Slicing occurs when an I frame appears and the slice file reaches 15 seconds.

Sample M3U8 file for audio

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:18
#EXT-X-DISCONTINUITY
#EXT-X-AGORA-TRACK-EVENT:EVENT=START,TRACK_TYPE=AUDIO,TIME=20190920125142289
#EXTINF:15.019000
sid713476478245_cnameagora__uid_s_123__uid_e_audio_20190920125142289.ts
#EXTINF:15.019000
sid713476478245_cnameagora__uid_s_123__uid_e_audio_20190920125157307.ts
#EXTINF:15.019000
sid713476478245_cnameagora__uid_s_123__uid_e_audio_20190920125212326.ts
#EXTINF:15.019000
sid713476478245_cnameagora__uid_s_123__uid_e_audio_20190920125227345.ts
#EXTINF:12.523000
sid713476478245_cnameagora__uid_s_123__uid_e_audio_20190920125242363.ts
#EXT-X-ENDLIST

Sample M3U8 file for video

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:18
#EXT-X-DISCONTINUITY
#EXT-X-AGORA-ROTATE:WIDTH=640,HEIGHT=480,ROTATE=0,TIME=20190920125142485
#EXT-X-AGORA-TRACK-EVENT:EVENT=START,TRACK_TYPE=VIDEO,TIME=20190920125142485
#EXTINF:6.332000
sid713476478245_cnameagora__uid_s_123__uid_e_video_20190920125142485.ts
#EXT-X-AGORA-ROTATE:WIDTH=1280,HEIGHT=720,ROTATE=0,TIME=20190920125149174
#EXT-X-DISCONTINUITY
#EXTINF:17.442000
sid713476478245_cnameagora__uid_s_123__uid_e_video_20190920125149174.ts
#EXT-X-DISCONTINUITY
#EXT-X-AGORA-ROTATE:WIDTH=640,HEIGHT=480,ROTATE=0,TIME=20190920125206616
#EXTINF:33.326000
sid713476478245_cnameagora__uid_s_123__uid_e_video_20190920125206616.ts
#EXT-X-DISCONTINUITY
#EXT-X-AGORA-ROTATE:WIDTH=1280,HEIGHT=720,ROTATE=0,TIME=20190920125239942
#EXTINF:14.815000
sid713476478245_cnameagora__uid_s_123__uid_e_video_20190920125239942.ts
#EXT-X-ENDLIST