Table of Contents generated with DocToc
- Pili Streaming Cloud server-side library for NodeJS
Pili Streaming Cloud server-side library for NodeJS
Features
- URL
- RTMP推流地址: RTMPPublishURL(domain, hub, streamKey, mac, expireAfterSeconds)
- RTMP直播地址: RTMPPlayURL(domain, hub, streamKey)
- HLS直播地址: HLSPlayURL(domain, hub, streamKey)
- HDL直播地址: HDLPlayURL(domain, hub, streamKey)
- 截图直播地址: SnapshotPlayURL(domain, hub, streamKey)
- Hub
- 创建流: hub.Create(streamKey)
- 获得流: hub.Stream(streamKey)
- 列出流: hub.List(prefix, limit, marker)
- 列出正在直播的流: hub.ListLive(prefix, limit, marker)
- 批量查询直播实时信息: hub.batchLiveStreamsInfo(items)
- Stream
- 流信息: stream.Info()
- 禁用流: stream.Disable()
- 启用流: stream.Enable()
- 查询直播状态: stream.LiveStatus()
- 保存直播回放: stream.Save(start, end)
- 查询直播历史: stream.HistoryActivity(start, end)
- 保存直播截图: stream.saveSnapshot()
- 修改流转码配置: stream.updateConverts(profiles)
Installaion
// install latest versionnpm install piliv2 --save
Usage
Configuration
var Pili = ; var ACCESS_KEY = 'QiniuAccessKey';var SECRET_KEY = 'QiniuSecretKey'; var HUB = 'PiliHubName'; // The Hub must be exists before use var credentials = ACCESS_KEY SECRET_KEY;
URL
Generate RTMP publish URL
var url = Pili;console;// rtmp://publish-rtmp.test.com/PiliSDKTest/streamkey?e=1466652726&token=9roGzeeJkZh4y5gHpzT7Uv1CIw0KiVV8K4dfXRY0:bYZGIdK-tjjAfyIwbShQ5Bb1kBY=
Generate RTMP play URL
var url = Pili;console;// rtmp://live-rtmp.test.com/PiliSDKTest/streamkey
Generate HLS play URL
var url = Pili;console;// http://live-rtmp.test.com/PiliSDKTest/streamkey.m3u8
Generate HDL play URL
var url = Pili;console;// http://live-rtmp.test.com/PiliSDKTest/streamkey.flv
Generate Snapshot play URL
var url = Pili;console;// http://live-rtmp.test.com/PiliSDKTest/streamkey.jpg
Hub
Instantiate a Pili Hub object
var hub = credentials HUB;
Create a new Stream
hub;
Get a Stream
var stream = hub; stream
LiveInfo
stream;
List Stream
var listOptions = 'liveonly': false 'prefix': '' 'limit': 2; var { if !err streams; if marker listOptionsmarker = marker; hub; else console; } hub;
Get Streams live status
hub;
Stream
Disable a Stream
stream;
Enable a Stream
stream;
Get Stream live status
stream;
Get Stream history activity
var publishHistoryOptions = start : null // optional, in second, unix timestamp end : null // optional, in second, unix timestamp;stream
Save Stream live playback
var savePlaybackOptions = start : null // optional, in second, unix timestamp end : null // optional, in second, unix timestamp format: null // optional, file format; stream;
Save Stream snapshot
var saveSnapshotOptions = fname: streamKey // optional, file name; stream;
Update Stream converts
stream