oss.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
  5. @AUTHOR: ASJRD018
  6. @NAME: AnsjerFormal
  7. @software: PyCharm
  8. @DATE: 2018/9/19 10:53
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: oss.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. from oss2 import *
  15. from oss2.models import *
  16. import time
  17. from var_dump import var_dump
  18. import urllib
  19. ###########
  20. host = "oss-cn-shenzhen.aliyuncs.com" # just for example
  21. accessid = "LTAIXSozepSx81xe"
  22. accesskey = "19BlxRiAHDPLx4mhz6vQZRuhK0eKed"
  23. bucket_name = "testrtmp"
  24. channel_name = "test-channel"
  25. auth = Auth(accessid, accesskey)
  26. bucket = Bucket(auth, host, bucket_name)
  27. ######################
  28. # 生成oss签名url
  29. url = bucket.sign_url('GET', 'output.m3u8', 60 * 60, params={'x-oss-process': 'hls/sign'})
  30. url = urllib.parse.unquote(url, encoding='utf-8', errors='replace')
  31. print(url)
  32. exit()
  33. # 播放m3u8
  34. # m3list = bucket.post_vod_playlist(channel_name=channel_name, playlist_name='test.m3u8', start_time=1537336020119,
  35. # end_time=1537336029318)
  36. # exit()
  37. # 获取推流地址
  38. channel_cfg = LiveChannelInfo(target=LiveChannelInfoTarget(frag_count=10))
  39. channel = bucket.create_live_channel(channel_name, channel_cfg)
  40. publish_url = channel.publish_url
  41. signed_publish_url = bucket.sign_rtmp_url("test-channel", "playlist.m3u8", 3600)
  42. print(signed_publish_url)
  43. '''
  44. 直播录制转为媒体文件
  45. https://help.aliyun.com/document_detail/64997.html?spm=a2c4g.11186623.2.11.78274c07rvcHUR
  46. '''
  47. from aliyunsdkcore import client
  48. # from aliyunsdklive