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)
def start_encode(): clientq = qencode.client(API_KEY) if clientq.error: raise QencodeClientException(clientq.message) print('The client created. Expire date: %s' % clientq.expire) task = clientq.create_task() if task.error: raise QencodeTaskException(task.message) fileUrl = task.upload_url + '/' + task.task_token res = tus_uploader.upload(file_path=file_path, url=fileUrl, log_func=log_upload, chunk_size=200000) params.source = res.url 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)
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() task.start_time = 0.0 task.duration = 10.0 if task.error: raise QencodeTaskException(task.message) task.start(TRANSCODING_PROFILEID, VIDEO_URL) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token # using callback methods task.progress_changed(progress_changed_handler) task.task_completed(task_completed_handler, task.task_token)
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) #get upload url from endpoint returned with /v1/create_task and task_token value uploadUrl = task.upload_url + '/' + task.task_token #do upload and get uploaded file URI uploadedFile = tus_uploader.upload(file_path=file_path, url=uploadUrl, log_func=log_upload, chunk_size=2000000) params = query % uploadedFile.url 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)
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) encryption_parameters, payload = cenc_drm(DRM_USERNAME, DRW_PASSWORD) #encryption_parameters, payload = fps_drm(DRM_USERNAME, DRW_PASSWORD) query = QUERY.replace('{cenc_drm}', json.dumps(encryption_parameters)) task.custom_start(query) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token while True: status = task.extend_status() # print status print json.dumps(status, indent=2, sort_keys=True) if status['error'] or status['status'] == 'completed': break time.sleep(5)
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() task.start_time = 0.0 task.duration = 10.0 if task.error: raise QencodeTaskException(task.message) task.start(TRANSCODING_PROFILEID, VIDEO_URL) #or stitch #task.start(TRANSCODING_PROFILEID, STITCH) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token while True: status = task.status() print json.dumps(status, indent=2, sort_keys=True) # print status if status['error'] or status['status'] == 'completed': break time.sleep(5)
def start_encode(): # this creates signed request to BuyDRM cpix_request = create_cpix_user_request(key_ids, media_id, USER_PVT_KEY_PATH, USER_PUB_CERT_PATH, use_playready=True, use_widevine=True) 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) query = QUERY.replace('{cpix_request}', base64.b64encode(cpix_request)) task.custom_start(query) 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)
#!/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 from qencode import QencodeClientException #replace with your API KEY (can be found in your Project settings on Qencode portal) API_KEY = 'your-api-qencode-key' VIDEO_URL = 'https://nyc3.s3.qencode.com/qencode/bbb_30s.mp4' client = qencode.client(API_KEY) if client.error: raise QencodeClientException(client.message) print 'The client created. Expire date: %s' % client.expire metadata = client.get_metadata(VIDEO_URL) print('Metadata: ' + metadata)