def get_rtmp_play(): if not request.json or not 'key' in request.json: abort(400) key = request.json['key'] rtmp_play = pili.rtmp_play_url("pili-live-rtmp.pearapple.net", hubName, key) up = {'user_key': key, 'rtmp_play': rtmp_play} return jsonify(up)
def gen_url(): mac = pili.Mac('illyLZP9RlWGikwwITutZvqqZTz73B8kTceDJ1gG', 'Qi3iL46RypaqivLD0_D7zRkijgD1jQEPdstMNh2w') hub = 'raspi' key = 'raspi_key' publish = 'pili-publish.raspi-live.buhuipao.com' rtmp = 'pili-live-rtmp.raspi-live.buhuipao.com' hls = 'pili-live-hls.raspi-live.buhuipao.com' publish_url = pili.rtmp_publish_url(publish, hub, key, mac, 3600) rtmp_url = pili.rtmp_play_url(rtmp, hub, key) print('rtmp player url: %s' % rtmp_url) hls_url = pili.hls_play_url(hls, hub, key) print('hls player url: %s' % hls_url) return publish_url
# 替换成自己 Qiniu 账号的 SecretKey secret_key = "..." domain = '...' hub_name = '...' stream_title = '...' expire = 3600 mac = pili.Mac(access_key, secret_key) client = pili.Client(mac) hub = client.hub(hub_name) stream = hub.get("...") print pili.rtmp_publish_url(domain, hub_name, stream_title, mac, expire) print pili.rtmp_play_url(domain, hub_name, stream_title) print pili.hls_play_url(domain, hub_name, stream_title) print pili.hdl_play_url(domain, hub_name, stream_title) print pili.snapshot_play_url(domain, hub_name, stream_title)
# 替换成自己 Qiniu 账号的 AccessKey access_key = "..." # 替换成自己 Qiniu 账号的 SecretKey secret_key = "..." domain = '...' hub_name = '...' stream_title = '...' expire = 3600 mac = pili.Mac(access_key, secret_key) client = pili.Client(mac) hub = client.hub(hub_name) stream = hub.get("...") print pili.rtmp_publish_url(domain, hub_name, stream_title, mac, expire) print pili.rtmp_play_url(domain, hub_name, stream_title) print pili.hls_play_url(domain, hub_name, stream_title) print pili.hdl_play_url(domain, hub_name, stream_title) print pili.snapshot_play_url(domain, hub_name, stream_title)
import pili, time mac = pili.Mac("AccessKey", "SecretKey") print pili.rtmp_publish_url("publish-rtmp.test.com", "PiliTest", "streamkey", mac, 60) print pili.rtmp_play_url("live-rtmp.test.com", "PiliTest", "streamkey") print pili.hls_play_url("live-rtmp.test.com", "PiliTest", "streamkey") print pili.hdl_play_url("live-rtmp.test.com", "PiliTest", "streamkey") print pili.snapshot_play_url("live-rtmp.test.com", "PiliTest", "streamkey") client = pili.Client(mac) hub = client.hub("PiliTest") ss = hub.list(liveonly=True) for i in ss["items"]: print i.key stream = hub.get("test1234") print stream.to_json() stream.disable() print stream.refresh().to_json() stream.enable() print stream.refresh().to_json() print stream.status() print stream.history() print stream.saveas()
stream = hub.get("test1") print "query stream live status:" print stream.status() now = int(time.time()) print "save stream playback:" print stream.saveas(start_second=now-300, fname="test1.m3u8") print "save stream snapshot:" print stream.snapshot(fname="test1.jpg") now = int(time.time()) print "get publish history:" print stream.history(start_second=now-86400) print "RTMP publish URL:" print pili.rtmp_publish_url("publish-rtmp.test.com", hub_name, "streamtitle", mac, 60) print "RTMP play URL:" print pili.rtmp_play_url("live-rtmp.test.com", hub_name, "streamtitle") print "HLS live URL:" print pili.hls_play_url("live-hls.test.com", hub_name, "streamtitle") print "HDL live URL:" print pili.hdl_play_url("live-hdl.test.com", hub_name, "streamtitle") print "snapshot URL:" print pili.snapshot_play_url("live-snapshot.test.com", hub_name, "streamtitle")
# 替换成自己 Qiniu 账号的 AccessKey access_key = "..." # 替换成自己 Qiniu 账号的 SecretKey secret_key = "..." hub_name = "..." domain = "..." stream_name = '123' expire = 3600 mac = Mac(access_key, secret_key) hub = Hub(mac, hub_name) stream = hub.get(stream_name) print(rtmp_publish_url(domain, hub_name, stream_name, mac, expire)) print(rtmp_play_url(domain, hub_name, stream_name)) print(hls_play_url(domain, hub_name, stream_name)) print(hdl_play_url(domain, hub_name, stream_name)) print(snapshot_play_url(domain, hub_name, stream_name))
print "query stream live status:" print stream.status() now = int(time.time()) print "save stream playback:" print stream.saveas(start_second=now - 300, fname="test1.m3u8") print "save stream snapshot:" print stream.snapshot(fname="test1.jpg") now = int(time.time()) print "get publish history:" print stream.history(start_second=now - 86400) print "RTMP publish URL:" print pili.rtmp_publish_url("publish-rtmp.test.com", hub_name, "streamtitle", mac, 60) print "RTMP play URL:" print pili.rtmp_play_url("live-rtmp.test.com", hub_name, "streamtitle") print "HLS live URL:" print pili.hls_play_url("live-hls.test.com", hub_name, "streamtitle") print "HDL live URL:" print pili.hdl_play_url("live-hdl.test.com", hub_name, "streamtitle") print "snapshot URL:" print pili.snapshot_play_url("live-snapshot.test.com", hub_name, "streamtitle")