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 = qencode3.client(API_KEY) if client.error: raise QencodeClientException(client.message) print('The client created. Expire date: {0}'.format(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: {0}'.format(task.task_token)) # using callback methods task.progress_changed(progress_changed_handler) task.task_completed(task_completed_handler, task.task_token)
def start_encode(): clientq = qencode3.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 = 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 get(self, uri): params = """ {"query": { "source": "%s", "format": [ {"output": "metadata", "metadata_version": "4.1.5"} ] } } """ % uri self.custom_start(params) while True: status = self.status() if status['error'] or status['status'] == 'completed': break time.sleep(5) if self.error: raise QencodeTaskException(self.message) url = None if len(status['videos']) > 0: url = status['videos'][0]['url'] elif len(status['audios']) > 0: url = status['audios'][0]['url'] if url is None: raise QencodeTaskException( 'No metadata URL found in status response') data = urllib2.urlopen(url).read() return data
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 = qencode3.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 = qencode3.client(API_KEY) if client.error: raise QencodeClientException(client.message) print('The client created. Expire date: {0}'.format(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: {0}'.format(task.task_token)) line = "-" * 80 while True: print(line) 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 = qencode3.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)