ElasticTranscoder.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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: Ansjer
  7. @software: PyCharm
  8. @DATE: 2018/5/17 10:09
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: ElasticTranscoderClassObject.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. from boto3.session import Session
  15. from Ansjer.config import *
  16. class ElasticTranscoder:
  17. def __init__(self, *args, **kwargs):
  18. self.access_id = AWS_ACCESS_ID,
  19. self.access_secret = AWS_ACCESS_SECRET,
  20. session = Session(
  21. aws_access_key_id=AWS_ACCESS_ID,
  22. aws_secret_access_key=AWS_ACCESS_SECRET,
  23. region_name=AWS_ACCESS_REGION,
  24. )
  25. self.conn = session.client('elastictranscoder')
  26. def create_job(self, InputKey='', OutputKey=''):
  27. response = self.conn.create_job(
  28. PipelineId='1526962004445-bmasp8',
  29. Input={
  30. 'Key': InputKey
  31. },
  32. Outputs=[
  33. {
  34. 'Key': OutputKey,
  35. 'PresetId': '1351620000001-200010',
  36. 'SegmentDuration': '2',
  37. }
  38. ]
  39. )
  40. print(response)
  41. if response['ResponseMetadata']['HTTPStatusCode'] == 201:
  42. return True
  43. else:
  44. return False