thumnber.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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: 2019/4/1 9:41
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: xls.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. import urllib
  15. import oss2
  16. OSS_STS_ACCESS_KEY = 'LTAIyMkGfEdogyL9'
  17. OSS_STS_ACCESS_SECRET = '71uIjpsqVOmF7DAITRyRuc259jHOjO'
  18. auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
  19. bucket_name = 'cnvod2'
  20. endpoint = 'oss-cn-shenzhen.aliyuncs.com'
  21. bucket = oss2.Bucket(auth, endpoint, bucket_name)
  22. ts = 'VVDHCVBYDKFMJRWA111A/vod1/1555646083/ts0.ts'
  23. url = bucket.sign_url('GET', ts, 36000, params={'x-oss-process': 'hls/sign'})
  24. urllst = url.split('?')
  25. url_start = urllib.parse.unquote(urllst[0])
  26. url_end = urllst[1]
  27. vod_play_url = '{url_start}?{url_end}'. \
  28. format(url_start=url_start, url_end=url_end)
  29. thumb0 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_0000,w_700'})
  30. thumb1 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_1000,w_700'})
  31. thumb2 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_2000,w_700'})
  32. thumb3 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_3000,w_700'})
  33. thumb4 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_4000,w_700'})
  34. print(thumb0)
  35. print(thumb1)
  36. print(thumb2)
  37. print(thumb3)
  38. print(thumb4)