Exemple #1
0
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 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)
Exemple #5
0
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)
Exemple #6
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import os.path
#import json
sys.path.append(
    os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
import qencode3
from qencode3 import QencodeClientException

#replace with your API KEY (can be found in your Project settings on Qencode portal)
API_KEY = ''
VIDEO_URL = 'https://nyc3.s3.qencode.com/qencode/bbb_30s.mp4'

client = qencode3.client(API_KEY)
if client.error:
    raise QencodeClientException(client.message)

print('The client created. Expire date: {0}'.format(client.expire))

metadata = client.get_metadata(VIDEO_URL)

try:
    metadata = metadata.decode("utf-8")
except Exception as e:
    pass

print(metadata)