edit-icon download-icon

Convert live recordings to media files

Last Updated: Feb 13, 2018

Live recordings use the original video resolution. You can use Media Processing (MPS) to convert a recorded original-resolution video to multiple media formats. To do this, you must first associate the live recordings with MPS.

Note: The input bucket for the MPS workflow and the bucket set for the live recordings must be the same. Otherwise, MPS console operations cannot be performed on the live recordings and the videos are not displayed on the MPS console.

Procedure

Step 1. Create a workflow

Before creating an MPS workflow, you must have created a Media Bucket on the MPS console. For details, see Library Settings. Then, create a workflow on the MPS console. Finally, select a workflow region. Only live videos in the China East 2 (Shanghai) and China North 2 (Beijing) regions are currently supported. The region in the Library Settings must be consistent with the region in the ApsaraVideo Live.

  1. Log on to the MPS console.

  2. Select the region.

  3. Click Library > Library Settings.

    2

  4. Click Media Buckets.

  5. Click Add and set the Input Media Bucket and Output Media Bucket.

    2

    Note:

    • To use MPS , you must create an Input Media Bucket and Output Media Bucket. The Input Media Bucket stores the original video files and the Output Media Bucket stores the transcoded video files. After the workflow is created, it obtains the original video files automatically from the Input Media Bucket and performs the corresponding transcoding operations.
    • Only Input Media Bucket in China East 2 are currently supported. When creating a media bucket, select China East 2.
  6. Create a workflow.

    In Workflows, click Create Workflow to go to the Workflow Manager page.

    1. Enter the workflow name.

    2. Set the Preset.

      Select Customize as the Preset. The Preset is the output scheme after transcoding and can be configured as needed.

      2

  7. Set the workflow parameters.

    The following describes the simplest operations to display quick experience of the live recording to video-on-demand process. For details, see Workflow settings.

    1. In the Topology field, add the Transcode node in the Input drop-down list.

      2

    2. Click the editting icon at the right side of the Input node.

      2

    3. Select the Input Bucket you created.

      2

    4. Set Transcode node.

      Click the editting icon at the right side of the Transcode node, select the Template and Output Bucket and click OK.

      2

    5. Click Next and enter the CDN domain name.

      2

      Note: The CDN domain name must complete an ICP filing and CNAME resolution.

      The workflow is added.

      2

Step 2. Create a live recording

  1. Log on to the ApsaraVideo Live console.

  2. Click Domains.

  3. Select the region.

  4. Select the expected domain name and click Detail at the right side.

    2

  5. Click Recording settings and click Create recording.

    2

  6. Add recording settings.

    1. On the Create recording page, enter theAppNamefor which to enable the recording function.

      2

      Note: The recordingAppNameand theAppNamein the stream push address must be the same. For example, if theAppNamein your stream push address is set tovideolive-en, the recordingAppNamemust also be videolive-en. For details, see Live streaming.

    2. Record format.

      Three Record formats are supported: flv, mp4, and m3u8. Here, m3u8 format simultaneously outputs ts fragment addresses.

    3. Storage Rules.

      The default storage path for recordings is:

      m3u8:record/{Date}/{AppName}/{StreamName}/{StartTime}_{EndTime}

      ts:record/{Date}/{AppName}/{StreamName}/{UnixTimestamp}_{Sequence}

      mp4:record/{Date}/{AppName}/{StreamName}/{StartTime}_{EndTime}

      flv:record/{Date}/{AppName}/{StreamName}/{StartTime}_{EndTime}

      In the example screenshot, the AppName is AppName, so the m3u8 and ts recording files are stored in the following path:

      m3u8:record/{Date}/APPName1/{StreamName}/{StartTime}_{EndTime}

      ts:record/{Date}/APPName1/{StreamName}/{UnixTimestamp}_{Sequence}

      If the default recording file storage path cannot meet your requirements, you can change it.

    4. Set the Store Path.

      Click Select, and in the dialogue box, click media Buckets and select the expected bucket name.

      2

      Note: Media buckets are primarily used to store videos for secondary transcoding. The live recordings can perform the transcoding workflow operation only when the bucket for storing the live recordings and the media bucket are the same input media bucket, If you haven’t activated the MPS and created a media bucket, this tag is not displayed.

    5. Recording Period.

      The system supports recording durations from 15 to 360 minutes (6 hours). After a recording exceeds six hours, a new file is generated according to the recording naming rules. However, the default length of ts fragments is 30 seconds.

    6. Recording file names.

      Here, { } represents a variable. The flv, mp4, and m3u8 formats support names in the following format: {AppName}, {StreamName}, {Date}, {Sequence}, {StartTime}, {EndTime}.Except for {StartTime} and {EndTime} the other variables can be retained or deleted as needed.TS recording files supports names in the format: {AppName}, {StreamName}, {Date}, {Sequence}, {UnixTimestamp}. These variables can be retained or deleted as needed.

      • {date} classifies recording files into folders by date. The default date format is “YYY-MM-DD”.

      • {StreamName} automatically fetches the StreamName and uses it as the storage path. You can manually change this as needed.You can customize the {streamName} according to your needs.

      • {Sequence} is the sequence variable.

      • {StartTime} is the recording start time and {EndTime} is the end time. The parameters of flv, mp4, and m3u8 files must have these variables.

      • {UnixTimestamp}_{Sequence} is the timestamp and sequence variable.In the names of ts files, this variable is automatically specified based on the file generation time and sequence.

      To maintain compatibility with the livestream push process, the live recording system judge a livestream to have ended when an interruption caused by network jitter or another problem persists for 180 seconds and the stream is not restored.The system independently stores the default recording index files in the format:{AppName}/{StreamName}/{Date}.m3u8(m3u8 format).

  7. Click OK to complete recording settings.

    In the Recording Settings tab, all the recording settings for the selected domain name are listed.

    2

    As a result, all the livestreams withAppName1as the AppName under the domain name follow these recording rules. Livestreams that occur before you finish configuring the settings do not trigger recording. Only new livestreams trigger recording (or an existing livestream that is interrupted for more than 180 seconds).

Step 3. Recording playback

After MTS transcoding, live recordings are stored in MTS. You can use MTS to play back the videos.

  • You can obtain the playback address and media ID of a single video file in Media Files on the MPS console, and play back the video.

    2

    Note:

    • The Transcoding ID is the ID of the on-demand video created from the recording file.

    • The Object Endpoint is the original file address of the live recording.

    2

    Note: Click Copy To to copy the recording file playback address.

  • To obtain the playback addresses of transcoded videos in batches, if you do not know the media IDs, you can use the media input addresses (the addresses used to store the original recording files) to query the media information using the API QueryMediaListByURL. For details, see Media ID query example.

    Note: Encrypted videos must be played using media IDs to ensure their security. Use Flash Player (HTML 5 does not support playback of encrypted videos) to play encrypted videos on web terminals. For details, see Introduction to media playback.

Thank you! We've received your feedback.