forked from Qencode-Corp/qencode-api-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_custom_mp4.py
More file actions
74 lines (53 loc) · 1.78 KB
/
start_custom_mp4.py
File metadata and controls
74 lines (53 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
import qencode
import time
import json
from qencode import QencodeClientException, QencodeTaskException
#replace with your API KEY (can be found in your Project settings on Qencode portal)
API_KEY = 'your-api-qencode-key'
params = qencode.custom_params()
FORMAT = qencode.format()
DESTINATION = qencode.destination()
# set your S3 access credentials here
# for more storage types see Destination object description: https://docs.qencode.com/#010_050
DESTINATION.url = "s3://s3-eu-west-2.amazonaws.com/qencode-test"
DESTINATION.key = "your-s3-key"
DESTINATION.secret = "your-s3-secret"
FORMAT.size = "320x240"
FORMAT.output = "mp4"
FORMAT.destination = DESTINATION
#replace with a link to your input video
params.source = 'https://qencode.com/static/1.mp4'
params.format = [FORMAT]
def start_encode():
"""
Create client object
:param api_key: string. required
:param api_url: string. not required
:param api_version: int. not required. default 'v1'
:return: task object
"""
client = qencode.client(API_KEY)
if client.error:
raise QencodeClientException(client.message)
print 'The client created. Expire date: %s' % client.expire
task = client.create_task()
if task.error:
raise QencodeTaskException(task.message)
task.custom_start(params)
if task.error:
raise QencodeTaskException(task.message)
print 'Start encode. Task: %s' % task.task_token
while True:
status = task.status()
# print status
print json.dumps(status, indent=2, sort_keys=True)
if status['error'] or status['status'] == 'completed':
break
time.sleep(5)
if __name__ == '__main__':
start_encode()