All Products
Search
Document Center

Object Storage Service:Manage LiveChannels (Node.js SDK)

Last Updated:Mar 20, 2026

Use the OSS Node.js SDK to create and manage LiveChannels for Real-Time Messaging Protocol (RTMP) stream ingest and HTTP Live Streaming (HLS) playback.

How it works

A LiveChannel is an RTMP stream ingest endpoint that OSS manages. When you create a LiveChannel, OSS returns an RTMP ingest URL and a playback URL. Audio and video data pushed to the ingest URL is split into .ts segments and assembled into an .m3u8 playlist for HLS playback.

The typical workflow:

  1. Create a LiveChannel to get the ingest URL and playback URL.

  2. Enable the channel (default status) to accept incoming streams.

  3. Check status to confirm the channel is receiving a stream.

  4. Generate a VOD playlist from recorded .ts segments when needed.

  5. Review history to see past stream ingest sessions.

  6. Delete the channel when it is no longer needed.

Prerequisites

Before you begin, ensure that you have:

  • An OSS bucket

  • The OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables set with valid access credentials

All examples in this topic use the following client initialization:

const OSS = require('ali-oss');

const store = new OSS({
  // Region where the bucket is located, for example: oss-cn-hangzhou
  region: 'yourRegion',
  // Read access credentials from environment variables
  accessKeyId: process.env.OSS_ACCESS_KEY_ID,
  accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
  authorizationV4: true,
  bucket: 'examplebucket',
});

Create a LiveChannel

Call putChannel() to create a LiveChannel. The operation returns an RTMP ingest URL and a playback URL.

const cid = 'mychannel';

const conf = {
  Description: 'this is my channel',
  Status: 'enabled',
  Target: {
    Type: 'HLS',
    FragDuration: '10',
    FragCount: '5',
    PlaylistName: 'playlist.m3u8',
  },
};

store.putChannel(cid, conf).then(r => console.log(r));

Parameters:

ParameterDescriptionConstraints
cidLiveChannel nameNo forward slashes (/) allowed
DescriptionChannel descriptionUp to 128 bytes
StatusInitial statusenabled or disabled
TypeDump formatOnly HLS is supported
FragDurationDuration of each .ts segment, in secondsExample: 10
FragCountNumber of .ts segments included in the .m3u8 playlistExample: 5
PlaylistNameName of the generated .m3u8 fileMust end with .m3u8; 6–128 bytes in length

Get LiveChannel information

Call getChannel() to retrieve the configuration of a LiveChannel.

const cid = 'mychannel';

store.getChannel(cid).then(r => console.log(r));

Set the LiveChannel status

Call putChannelStatus() to enable or disable a LiveChannel.

const cid = 'mychannel';

store.putChannelStatus(cid, 'disabled').then(r => console.log(r));
Note

When you disable a LiveChannel, OSS blocks all incoming stream ingest. If a client is currently streaming to the channel, it is disconnected after approximately 10 seconds.

Get LiveChannel status information

Call getChannelStatus() to retrieve the current stream ingest status of a LiveChannel.

const cid = 'mychannel';

store.getChannelStatus(cid).then(r => console.log(r));

Generate a LiveChannel playlist

Call createVod() to generate a video-on-demand (VOD) playlist for a LiveChannel. OSS queries the .ts segments recorded within the specified time range and combines them into an .m3u8 playlist file.

const cid = 'mychannel';

store.createVod(cid, 're-play', {
  startTime: 1460464870,  // UNIX timestamp
  endTime: 1460465877,    // UNIX timestamp
}).then(r => console.log(r));

Parameters:

ParameterDescriptionConstraints
startTimeStart of the time range to query for .ts segmentsUNIX timestamp; must be earlier than endTime
endTimeEnd of the time range to query for .ts segmentsUNIX timestamp; the time span cannot exceed one day

List specific LiveChannels

Call listChannels() to list LiveChannels in a bucket, with optional prefix filtering and result limits.

store.listChannels({
  prefix: 'my',
  'max-keys': 3,
}).then(r => console.log(r));

Parameters:

ParameterDescriptionExample
prefixFilter channels by name prefix'my' returns channels whose names start with my
max-keysMaximum number of channels to return3

Get LiveChannel stream ingest records

Call getChannelHistory() to retrieve past stream ingest records for a LiveChannel. This operation returns the last 10 stream ingest records.

const cid = 'mychannel';

store.getChannelHistory(cid).then(r => console.log(r));

Delete a LiveChannel

Call deleteChannel() to delete a LiveChannel.

Important

You cannot delete a LiveChannel while a client is actively ingesting a stream to it. The delete request fails if a stream ingest session is in progress. Deleting a LiveChannel removes only the channel itself—the .ts segments and .m3u8 files generated from previous stream ingest sessions are not deleted.

const cid = 'mychannel';

store.deleteChannel(cid).then(r => console.log(r));

What's next

For the full API specification of each operation used in this topic, see: