├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── VERSION ├── bitcodin ├── __init__.py ├── api.py ├── error.py ├── exceptions.py ├── resource.py ├── rest.py ├── test │ ├── __init__.py │ ├── bitcodin_test_case.py │ ├── config.py │ ├── core │ │ ├── __init__.py │ │ ├── testcase_api_key_authorized.py │ │ ├── testcase_api_key_unauthorized.py │ │ ├── testcase_bitcodinobject.py │ │ ├── testcase_convert.py │ │ ├── testcase_convert_dict.py │ │ ├── testcase_create_headers.py │ │ └── testcase_get_api_base.py │ ├── encodingprofile │ │ ├── __init__.py │ │ ├── testcase_create_encoding_profile.py │ │ ├── testcase_create_encoding_profile_cropping_config.py │ │ ├── testcase_create_encoding_profile_incomplete_data.py │ │ ├── testcase_create_encoding_profile_invalid_data.py │ │ ├── testcase_create_encoding_profile_rotation.py │ │ ├── testcase_create_encoding_profile_sample_rate.py │ │ ├── testcase_create_encoding_profile_segment_length.py │ │ ├── testcase_create_encoding_profile_watermarked.py │ │ ├── testcase_delete_encoding_profile.py │ │ ├── testcase_delete_non_existent_encoding_profile.py │ │ ├── testcase_get_encoding_profile.py │ │ ├── testcase_get_list_encoding_profiles.py │ │ └── testcase_get_non_existent_encoding_profile.py │ ├── http │ │ ├── __init__.py │ │ ├── testcase_delete_undefined.py │ │ ├── testcase_get_undefined.py │ │ └── testcase_post_undefined.py │ ├── input │ │ ├── __init__.py │ │ ├── testcase_analyze_input.py │ │ ├── testcase_analyze_non_existent_input.py │ │ ├── testcase_create_azure_input.py │ │ ├── testcase_create_input.py │ │ ├── testcase_create_input_async.py │ │ ├── testcase_create_input_incomplete_data.py │ │ ├── testcase_create_input_invalid_data.py │ │ ├── testcase_create_s3_input.py │ │ ├── testcase_delete_input.py │ │ ├── testcase_delete_non_existent_input.py │ │ ├── testcase_get_input.py │ │ ├── testcase_get_list_inputs.py │ │ └── testcase_get_non_existent_input.py │ ├── job │ │ ├── __init__.py │ │ ├── testcase_autotransfer_job_ftp.py │ │ ├── testcase_autotransfer_job_gcs.py │ │ ├── testcase_autotransfer_job_s3.py │ │ ├── testcase_create_job.py │ │ ├── testcase_create_job_azure_input.py │ │ ├── testcase_create_job_cropping_video.py │ │ ├── testcase_create_job_deinterlace.py │ │ ├── testcase_create_job_hls_encryption.py │ │ ├── testcase_create_job_incomplete_data.py │ │ ├── testcase_create_job_invalid_data.py │ │ ├── testcase_create_job_keep_aspect_ratio.py │ │ ├── testcase_create_job_merge_audio_channels.py │ │ ├── testcase_create_job_merge_audio_channels_multi.py │ │ ├── testcase_create_job_mp3_audio_only.py │ │ ├── testcase_create_job_multiple_audio_streams.py │ │ ├── testcase_create_job_playready_drm.py │ │ ├── testcase_create_job_playready_drm_invalid.py │ │ ├── testcase_create_job_playready_widevine_drm.py │ │ ├── testcase_create_job_playready_widevine_drm_invalid.py │ │ ├── testcase_create_job_rotation.py │ │ ├── testcase_create_job_s3_input.py │ │ ├── testcase_create_job_skip_analysis.py │ │ ├── testcase_create_job_specific_segment_length.py │ │ ├── testcase_create_job_specific_video_audio_sample_rates.py │ │ ├── testcase_create_job_watermarked.py │ │ ├── testcase_create_job_widevine_drm.py │ │ ├── testcase_create_job_widevine_drm_invalid_config.py │ │ ├── testcase_create_thumbnail.py │ │ ├── testcase_get_job.py │ │ ├── testcase_get_job_status.py │ │ ├── testcase_get_list_jobs.py │ │ ├── testcase_get_non_existent_job.py │ │ ├── testcase_transfer_job_azure.py │ │ ├── testcase_transfer_job_ftp.py │ │ ├── testcase_transfer_job_gcs.py │ │ ├── testcase_transfer_job_s3.py │ │ └── testcase_transfer_job_to_non_existent_output.py │ ├── live_stream │ │ ├── __init__.py │ │ └── testcase_create_delete_live_stream.py │ ├── main.py │ ├── notifications │ │ ├── __init__.py │ │ ├── testcase_delete_subscription.py │ │ ├── testcase_get_list_events.py │ │ ├── testcase_get_list_subscriptions.py │ │ └── testcase_get_subscription.py │ ├── output │ │ ├── __init__.py │ │ ├── testcase_create_azure_output.py │ │ ├── testcase_create_ftp_output.py │ │ ├── testcase_create_ftp_output_incomplete.py │ │ ├── testcase_create_ftp_output_invalid.py │ │ ├── testcase_create_gcs_output.py │ │ ├── testcase_create_s3_output.py │ │ ├── testcase_create_s3_output_incomplete.py │ │ ├── testcase_create_s3_output_invalid.py │ │ ├── testcase_delete_ftp_output.py │ │ ├── testcase_delete_gcs_output.py │ │ ├── testcase_delete_s3_output.py │ │ ├── testcase_get_ftp_output.py │ │ ├── testcase_get_gcs_output.py │ │ ├── testcase_get_non_existent_output.py │ │ └── testcase_get_s3_output.py │ ├── settings.py.enc │ └── statistics │ │ ├── __init__.py │ │ ├── testcase_get_statistics_current.py │ │ └── testcase_get_statistics_from_to.py └── util.py ├── examples ├── create_job.py ├── create_job_autotransfer_azure.py ├── create_job_autotransfer_s3.py ├── create_job_azure_input.py ├── create_job_closed_captions_multiple_audio_streams.py ├── create_job_cropping_video.py ├── create_job_deinterlace.py ├── create_job_encrypted_dash_and_hls.py ├── create_job_fairplay_encryption.py ├── create_job_get_manifest_info.py ├── create_job_hevc.py ├── create_job_hls_encryption.py ├── create_job_keep_aspect_ratio.py ├── create_job_location.py ├── create_job_merge_audio_channels.py ├── create_job_merge_audio_channels_multi.py ├── create_job_mp3_audio_only.py ├── create_job_multiple_audio_streams.py ├── create_job_playready_drm.py ├── create_job_rotation.py ├── create_job_s3_input.py ├── create_job_widevine_drm.py ├── create_job_widevine_playready_combined_drm.py ├── create_job_with_duration_and_start_time.py ├── create_job_with_specific_segment_length.py ├── create_job_with_specific_video_audio_sample_rates.py ├── create_job_with_transfer_to_s3.py ├── create_job_with_transmuxing.py ├── create_job_with_watermark.py ├── create_live_stream.py ├── create_sprite.py ├── create_thumbnail.py └── create_vtt_mpd.py ├── requirements.txt └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # project specific 2 | bitcodin/test/settings.py 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | env/ 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .coverage 43 | .coverage.* 44 | .cache 45 | nosetests.xml 46 | coverage.xml 47 | *,cover 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | 56 | # Sphinx documentation 57 | docs/_build/ 58 | 59 | # PyBuilder 60 | target/ 61 | 62 | # PyCharm 63 | .idea/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - '2.7' 4 | - '3.4' 5 | notifications: 6 | email: 7 | - david.moser@bitmovin.net 8 | - dominic.miglar@bitmovin.net 9 | - bitcodin-python@bitmovin.net 10 | branches: 11 | only: 12 | - master 13 | install: 14 | - pip install -r requirements.txt 15 | script: 16 | - travis_wait 30 coverage run --source bitcodin -m bitcodin.test.main 17 | after_success: 18 | - coveralls 19 | before_install: 20 | - openssl aes-256-cbc -K $encrypted_86e5c45279d5_key -iv $encrypted_86e5c45279d5_iv -in bitcodin/test/settings.py.enc -out bitcodin/test/settings.py -d 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This API client is deprecated! 2 | This API client works with our previous encoding service available at https://app.bitmovin.com only, which is no longer available to new customers. So, if you are planning to integrate our services, please use our new Bitmovin API which is available at [https://dashboard.bitmovin.com ](https://dashboard.bitmovin.com) and its new API clients! 3 | 4 | --- 5 | 6 | **Bitmovin Python API Client**: [https://github.com/bitmovin/bitmovin-python](https://github.com/bitmovin/bitmovin-python) 7 | 8 | **Bitmovin API documentation:** [https://developer.bitmovin.com/hc](https://developer.bitmovin.com/hc) -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.6.9 -------------------------------------------------------------------------------- /bitcodin/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'dmoser' 2 | 3 | # Configuration variables 4 | 5 | api_key = None 6 | api_base = 'https://portal.bitcodin.com/api' 7 | api_version = None 8 | 9 | from bitcodin.resource import * 10 | from bitcodin.api import * 11 | -------------------------------------------------------------------------------- /bitcodin/error.py: -------------------------------------------------------------------------------- 1 | __author__ = 'David Moser ' 2 | -------------------------------------------------------------------------------- /bitcodin/exceptions.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar' 2 | 3 | import datetime 4 | 5 | 6 | class BitcodinError(Exception): 7 | def __init__(self, message, error): 8 | self.message = message 9 | self.error = error 10 | 11 | def __str__(self): 12 | error_string = super(BitcodinError, self).__str__() 13 | return '%s\nError Message: %s\nAPI Response: %s\nOccurred at: %s' % (error_string, self.message, self.error, 14 | datetime.datetime.now()) 15 | 16 | 17 | class BitcodinInternalServerError(BitcodinError): 18 | pass 19 | 20 | 21 | class BitcodinBadRequestError(BitcodinError): 22 | pass 23 | 24 | 25 | class BitcodinNotFoundError(BitcodinError): 26 | pass 27 | 28 | 29 | class BitcodinApiKeyNotAuthorizedError(BitcodinError): 30 | pass 31 | 32 | 33 | class BitcodinApiKeyNotSetError(BitcodinError): 34 | pass 35 | -------------------------------------------------------------------------------- /bitcodin/rest.py: -------------------------------------------------------------------------------- 1 | __author__ = 'David Moser ' 2 | 3 | import requests 4 | 5 | from .exceptions import BitcodinError 6 | from .exceptions import BitcodinInternalServerError 7 | from .exceptions import BitcodinApiKeyNotAuthorizedError 8 | from .exceptions import BitcodinBadRequestError 9 | from .exceptions import BitcodinNotFoundError 10 | 11 | 12 | class RestClient(object): 13 | 14 | def __init__(self): 15 | pass 16 | 17 | @staticmethod 18 | def _raise_error(result): 19 | if result.status_code == 500: 20 | raise BitcodinInternalServerError('An HTTP 500 Internal Server Error occured', result.text) 21 | 22 | try: 23 | json_result = result.json() 24 | except ValueError: 25 | raise BitcodinError('An error occured which response could not be JSON-decoded.', result.text) 26 | 27 | if result.status_code == 404: 28 | raise BitcodinNotFoundError( 29 | 'The API URL you requested does not exist', 30 | json_result 31 | ) 32 | elif result.status_code == 401: 33 | raise BitcodinApiKeyNotAuthorizedError( 34 | 'The API Key used in the request was not authorized to access the API.', 35 | json_result 36 | ) 37 | elif result.status_code == 400: 38 | raise BitcodinBadRequestError('The API received a invalid request.', json_result) 39 | else: 40 | raise BitcodinError('An error occured while communicating with the bitcodin API', json_result) 41 | 42 | @staticmethod 43 | def post(url=None, headers=None, content=None): 44 | result = requests.post(url, data=content, headers=headers) 45 | 46 | if result.status_code == 201 or result.status_code == 200: 47 | if result.text == '': 48 | return result.text 49 | return result.json() 50 | else: 51 | RestClient._raise_error(result) 52 | 53 | @staticmethod 54 | def get(url=None, headers=None): 55 | result = requests.get(url, headers=headers) 56 | 57 | if result.status_code != 200: 58 | RestClient._raise_error(result) 59 | 60 | return result.json() 61 | 62 | @staticmethod 63 | def put(self): 64 | pass 65 | 66 | @staticmethod 67 | def patch(url=None, headers=None, content=None): 68 | result = requests.patch(url, data=content, headers=headers) 69 | 70 | if result.status_code != 200: 71 | RestClient._raise_error(result) 72 | 73 | return result.json() 74 | 75 | @staticmethod 76 | def delete(url=None, headers=None): 77 | result = requests.delete(url, headers=headers) 78 | 79 | if result.status_code == 204: 80 | return True 81 | elif result.status_code == 200: 82 | return result.json() 83 | else: 84 | RestClient._raise_error(result) 85 | -------------------------------------------------------------------------------- /bitcodin/test/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'dmoser' 2 | -------------------------------------------------------------------------------- /bitcodin/test/bitcodin_test_case.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | 3 | import unittest 4 | import bitcodin 5 | from bitcodin.test.settings import api_key 6 | from bitcodin import get_job 7 | 8 | __author__ = 'Dominic Miglar ' 9 | 10 | 11 | class BitcodinTestCase(unittest.TestCase): 12 | def setUp(self): 13 | bitcodin.api_key = api_key 14 | 15 | def tearDown(self): 16 | bitcodin.api_key = None 17 | 18 | def wait_until_job_finished(self, job_id): 19 | job_result = get_job(job_id) 20 | 21 | while job_result.status != 'Finished': 22 | job_result = get_job(job_result.job_id) 23 | self.assertNotEqual(job_result.status, 'Error') 24 | print(job_result.to_json()) 25 | sleep(5) 26 | -------------------------------------------------------------------------------- /bitcodin/test/config.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | # bitcodin-python test configuration 4 | # Please do not place sensitive information here -> 5 | # for sensitive information see settings.py (Encrypt for travis tests!) 6 | 7 | test_video_url = 'http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv' 8 | test_video_url_multiple_audio_streams = 'http://bitbucketireland.s3.amazonaws.com/Sintel-two-audio-streams-short.mkv' -------------------------------------------------------------------------------- /bitcodin/test/core/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | from unittest import TestSuite 4 | 5 | from .testcase_api_key_authorized import ApiKeyAuthorizedTestCase 6 | from .testcase_api_key_unauthorized import ApiKeyUnauthorizedTestCase 7 | from .testcase_create_headers import CreateHttpHeadersTestCase 8 | from .testcase_convert import ConvertTestCase 9 | from .testcase_convert_dict import ConvertDictTestCase 10 | from .testcase_get_api_base import GetApiBaseTestCase 11 | from .testcase_bitcodinobject import BitcodinObjectBooleanTestCase 12 | from .testcase_bitcodinobject import BitcodinObjectLengthTestCase 13 | 14 | 15 | def get_test_suite(): 16 | test_suite = TestSuite() 17 | test_suite.addTest(ConvertTestCase()) 18 | test_suite.addTest(ConvertDictTestCase()) 19 | test_suite.addTest(GetApiBaseTestCase()) 20 | test_suite.addTest(CreateHttpHeadersTestCase()) 21 | test_suite.addTest(ApiKeyAuthorizedTestCase()) 22 | test_suite.addTest(ApiKeyUnauthorizedTestCase()) 23 | test_suite.addTest(BitcodinObjectBooleanTestCase()) 24 | test_suite.addTest(BitcodinObjectLengthTestCase()) 25 | return test_suite 26 | -------------------------------------------------------------------------------- /bitcodin/test/core/testcase_api_key_authorized.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | 5 | import bitcodin 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | from bitcodin.exceptions import BitcodinNotFoundError 8 | from bitcodin.rest import RestClient 9 | 10 | 11 | class ApiKeyAuthorizedTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(ApiKeyAuthorizedTestCase, self).setUp() 14 | 15 | def runTest(self): 16 | with self.assertRaises(BitcodinNotFoundError): 17 | response = RestClient.get(url=bitcodin.get_api_base(), headers=bitcodin.create_headers()) 18 | 19 | def tearDown(self): 20 | super(ApiKeyAuthorizedTestCase, self).tearDown() 21 | 22 | 23 | if __name__ == '__main__': 24 | unittest.main() 25 | -------------------------------------------------------------------------------- /bitcodin/test/core/testcase_api_key_unauthorized.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | 5 | import bitcodin 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | from bitcodin.exceptions import BitcodinApiKeyNotAuthorizedError 8 | from bitcodin.rest import RestClient 9 | 10 | 11 | class ApiKeyUnauthorizedTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(ApiKeyUnauthorizedTestCase, self).setUp() 14 | bitcodin.api_key = 'A_SUPER_FANCY_INVALID_KEY' 15 | 16 | def runTest(self): 17 | with self.assertRaises(BitcodinApiKeyNotAuthorizedError): 18 | response = RestClient.get(url=bitcodin.get_api_base(), headers=bitcodin.create_headers()) 19 | 20 | def tearDown(self): 21 | super(ApiKeyUnauthorizedTestCase, self).tearDown() 22 | 23 | if __name__ == '__main__': 24 | unittest.main() 25 | -------------------------------------------------------------------------------- /bitcodin/test/core/testcase_bitcodinobject.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Jan Češpivo ' 2 | 3 | import unittest 4 | 5 | from bitcodin.resource import BitcodinObject 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class BitcodinObjectBooleanTestCase(BitcodinTestCase): 10 | def test_not_empty(self): 11 | not_empty_bitcodin_object = BitcodinObject({'some_key': 'some_value'}) 12 | boolean_representation = bool(not_empty_bitcodin_object) 13 | self.assertEqual(boolean_representation, True) 14 | 15 | def test_empty(self): 16 | empty_bitcodin_object = BitcodinObject({}) 17 | boolean_representation = bool(empty_bitcodin_object) 18 | self.assertEqual(boolean_representation, False) 19 | 20 | 21 | class BitcodinObjectLengthTestCase(BitcodinTestCase): 22 | def test_not_empty(self): 23 | not_empty_bitcodin_object = BitcodinObject({'some_key': 'some_value'}) 24 | length = len(not_empty_bitcodin_object) 25 | self.assertEqual(length, 1) 26 | 27 | def test_empty(self): 28 | empty_bitcodin_object = BitcodinObject({}) 29 | length = len(empty_bitcodin_object) 30 | self.assertEqual(length, 0) 31 | 32 | 33 | if __name__ == '__main__': 34 | unittest.main() 35 | -------------------------------------------------------------------------------- /bitcodin/test/core/testcase_convert.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | 5 | from bitcodin.util import convert 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class ConvertTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(ConvertTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | camel_case = 'pythonsDontEatCamels' 15 | snake_case = convert(camel_case) 16 | self.assertEqual(snake_case, 'pythons_dont_eat_camels') 17 | 18 | def tearDown(self): 19 | super(ConvertTestCase, self).tearDown() 20 | 21 | 22 | if __name__ == '__main__': 23 | unittest.main() 24 | -------------------------------------------------------------------------------- /bitcodin/test/core/testcase_convert_dict.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | 5 | from bitcodin.util import convert_dict 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class ConvertDictTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(ConvertDictTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | d = { 15 | 'camelCaseAttr': 'camelCaseContent', 16 | 'AnotherCamel': 'CamelContent', 17 | 'camelCamel': '_Camel' 18 | } 19 | converted = { 20 | 'camel_case_attr': 'camelCaseContent', 21 | 'another_camel': 'CamelContent', 22 | 'camel_camel': '_Camel' 23 | } 24 | 25 | snake_dict = convert_dict(d) 26 | self.assertDictEqual(converted, snake_dict) 27 | 28 | def tearDown(self): 29 | super(ConvertDictTestCase, self).tearDown() 30 | 31 | 32 | if __name__ == '__main__': 33 | unittest.main() 34 | -------------------------------------------------------------------------------- /bitcodin/test/core/testcase_create_headers.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | 5 | import bitcodin 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class CreateHttpHeadersTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(CreateHttpHeadersTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | expected_headers = { 15 | 'Content-Type': 'application/json', 16 | 'bitcodin-api-key': bitcodin.api_key 17 | } 18 | headers = bitcodin.create_headers() 19 | self.assertDictEqual(expected_headers, headers) 20 | 21 | def tearDown(self): 22 | super(CreateHttpHeadersTestCase, self).tearDown() 23 | 24 | 25 | if __name__ == '__main__': 26 | unittest.main() 27 | -------------------------------------------------------------------------------- /bitcodin/test/core/testcase_get_api_base.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | 5 | import bitcodin 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class GetApiBaseTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(GetApiBaseTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | api_base = bitcodin.api_base 15 | api_base_got = bitcodin.get_api_base() 16 | self.assertEqual(api_base, api_base_got) 17 | 18 | def tearDown(self): 19 | super(GetApiBaseTestCase, self).tearDown() 20 | 21 | 22 | if __name__ == '__main__': 23 | unittest.main() 24 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | from unittest import TestSuite 4 | 5 | from .testcase_create_encoding_profile_incomplete_data import CreateEncodingProfileIncompleteDataTestCase 6 | from .testcase_create_encoding_profile_invalid_data import CreateEncodingProfileInvalidDataTestCase 7 | from .testcase_get_non_existent_encoding_profile import GetNonExistentEncodingProfileTestCase 8 | from .testcase_create_encoding_profile import CreateEncodingProfileTestCase 9 | from .testcase_get_encoding_profile import GetEncodingProfileTestCase 10 | from .testcase_delete_encoding_profile import DeleteEncodingProfileTestCase 11 | from .testcase_delete_non_existent_encoding_profile import DeleteNonExistentEncodingProfileTestCase 12 | from .testcase_get_list_encoding_profiles import GetEncodingProfileListTestCase 13 | from .testcase_create_encoding_profile_rotation import CreateEncodingProfileWithRotationTestCase 14 | from .testcase_create_encoding_profile_segment_length import CreateEncodingProfileWithSpecificSegmentLengthTestCase 15 | from .testcase_create_encoding_profile_sample_rate import CreateEncodingProfileWithSpecificSampleRatesTestCase 16 | from .testcase_create_encoding_profile_watermarked import CreateEncodingProfileWithWatermarkTestCase 17 | from .testcase_create_encoding_profile_cropping_config import CreateEncodingProfileWithCroppingConfigTestCase 18 | 19 | 20 | def get_test_suite(): 21 | test_suite = TestSuite() 22 | test_suite.addTest(CreateEncodingProfileIncompleteDataTestCase()) 23 | test_suite.addTest(CreateEncodingProfileInvalidDataTestCase()) 24 | test_suite.addTest(GetNonExistentEncodingProfileTestCase()) 25 | test_suite.addTest(CreateEncodingProfileTestCase()) 26 | test_suite.addTest(GetEncodingProfileTestCase()) 27 | test_suite.addTest(DeleteEncodingProfileTestCase()) 28 | test_suite.addTest(DeleteNonExistentEncodingProfileTestCase()) 29 | test_suite.addTest(GetEncodingProfileListTestCase()) 30 | test_suite.addTest(CreateEncodingProfileWithRotationTestCase()) 31 | test_suite.addTest(CreateEncodingProfileWithSpecificSegmentLengthTestCase()) 32 | test_suite.addTest(CreateEncodingProfileWithSpecificSampleRatesTestCase()) 33 | test_suite.addTest(CreateEncodingProfileWithWatermarkTestCase()) 34 | test_suite.addTest(CreateEncodingProfileWithCroppingConfigTestCase()) 35 | return test_suite 36 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_create_encoding_profile.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import EncodingProfile 5 | from bitcodin import AudioStreamConfig 6 | from bitcodin import VideoStreamConfig 7 | from bitcodin import create_encoding_profile 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class CreateEncodingProfileTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(CreateEncodingProfileTestCase, self).setUp() 15 | 16 | def runTest(self): 17 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 18 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 19 | profile='Main', preset='premium', height=480, width=640) 20 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 21 | result = create_encoding_profile(encoding_profile) 22 | self.encoding_profile = result 23 | self.assertEquals(result.name, 'API Test Profile') 24 | self.assertEquals(result.video_stream_configs[0].default_stream_id, 1) 25 | self.assertEquals(result.video_stream_configs[0].bitrate, 512000) 26 | self.assertEquals(result.video_stream_configs[0].profile, 'Main') 27 | self.assertEquals(result.video_stream_configs[0].preset.lower(), 'premium') 28 | self.assertEquals(result.video_stream_configs[0].height, 480) 29 | self.assertEquals(result.video_stream_configs[0].width, 640) 30 | self.assertEquals(result.audio_stream_configs[0].default_stream_id, 0) 31 | self.assertEquals(result.audio_stream_configs[0].bitrate, 192000) 32 | 33 | def tearDown(self): 34 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 35 | super(CreateEncodingProfileTestCase, self).tearDown() 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_create_encoding_profile_cropping_config.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import EncodingProfile 5 | from bitcodin import AudioStreamConfig 6 | from bitcodin import VideoStreamConfig 7 | from bitcodin import CroppingConfig 8 | from bitcodin import create_encoding_profile 9 | from bitcodin import delete_encoding_profile 10 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 11 | 12 | 13 | class CreateEncodingProfileWithCroppingConfigTestCase(BitcodinTestCase): 14 | def setUp(self): 15 | super(CreateEncodingProfileWithCroppingConfigTestCase, self).setUp() 16 | 17 | def runTest(self): 18 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 19 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 20 | profile='Main', preset='premium', height=480, width=640) 21 | 22 | cropping_config = CroppingConfig( 23 | top=100, 24 | bottom=100, 25 | left=5, 26 | right=50 27 | ) 28 | 29 | encoding_profile = EncodingProfile( 30 | name='API Test Profile', 31 | video_stream_configs=[video_stream_config], 32 | audio_stream_configs=[audio_stream_config], 33 | cropping_config=cropping_config 34 | ) 35 | 36 | result = create_encoding_profile(encoding_profile) 37 | self.encoding_profile = result 38 | self.assertEquals(result.name, 'API Test Profile') 39 | self.assertEquals(result.video_stream_configs[0].default_stream_id, 1) 40 | self.assertEquals(result.video_stream_configs[0].bitrate, 512000) 41 | self.assertEquals(result.video_stream_configs[0].profile, 'Main') 42 | self.assertEquals(result.video_stream_configs[0].preset.lower(), 'premium') 43 | self.assertEquals(result.video_stream_configs[0].height, 480) 44 | self.assertEquals(result.video_stream_configs[0].width, 640) 45 | self.assertEquals(result.audio_stream_configs[0].default_stream_id, 0) 46 | self.assertEquals(result.audio_stream_configs[0].bitrate, 192000) 47 | self.assertEquals(result.cropping_config.top, 100) 48 | self.assertEquals(result.cropping_config.bottom, 100) 49 | self.assertEquals(result.cropping_config.left, 5) 50 | self.assertEquals(result.cropping_config.right, 50) 51 | 52 | def tearDown(self): 53 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 54 | super(CreateEncodingProfileWithCroppingConfigTestCase, self).tearDown() 55 | 56 | 57 | if __name__ == '__main__': 58 | unittest.main() 59 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_create_encoding_profile_incomplete_data.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import AudioStreamConfig 5 | from bitcodin import VideoStreamConfig 6 | from bitcodin import EncodingProfile 7 | from bitcodin import create_encoding_profile 8 | from bitcodin.exceptions import BitcodinBadRequestError 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class CreateEncodingProfileIncompleteDataTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(CreateEncodingProfileIncompleteDataTestCase, self).setUp() 15 | 16 | def runTest(self): 17 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 18 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 19 | profile='', preset='', height=480, width=640) 20 | 21 | encoding_profile = EncodingProfile('API Test Profile X', [video_stream_config], [audio_stream_config]) 22 | with self.assertRaises(BitcodinBadRequestError): 23 | result = create_encoding_profile(encoding_profile) 24 | 25 | def tearDown(self): 26 | super(CreateEncodingProfileIncompleteDataTestCase, self).tearDown() 27 | 28 | 29 | if __name__ == '__main__': 30 | unittest.main() 31 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_create_encoding_profile_invalid_data.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import AudioStreamConfig 5 | from bitcodin import VideoStreamConfig 6 | from bitcodin import EncodingProfile 7 | from bitcodin import create_encoding_profile 8 | from bitcodin.exceptions import BitcodinBadRequestError 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class CreateEncodingProfileInvalidDataTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(CreateEncodingProfileInvalidDataTestCase, self).setUp() 15 | 16 | def runTest(self): 17 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 18 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 19 | profile='Mainerr', preset='nonexpreset', height=480, width=640) 20 | 21 | encoding_profile = EncodingProfile('API Test Profile X', [video_stream_config], [audio_stream_config]) 22 | with self.assertRaises(BitcodinBadRequestError): 23 | result = create_encoding_profile(encoding_profile) 24 | 25 | def tearDown(self): 26 | super(CreateEncodingProfileInvalidDataTestCase, self).tearDown() 27 | 28 | 29 | if __name__ == '__main__': 30 | unittest.main() 31 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_create_encoding_profile_rotation.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import EncodingProfile 5 | from bitcodin import AudioStreamConfig 6 | from bitcodin import VideoStreamConfig 7 | from bitcodin import create_encoding_profile 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class CreateEncodingProfileWithRotationTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(CreateEncodingProfileWithRotationTestCase, self).setUp() 15 | 16 | def runTest(self): 17 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 18 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 19 | profile='Main', preset='premium', height=480, width=640) 20 | encoding_profile = EncodingProfile( 21 | name='API Test Profile', 22 | video_stream_configs=[video_stream_config], 23 | audio_stream_configs=[audio_stream_config], 24 | rotation=45, 25 | ) 26 | 27 | result = create_encoding_profile(encoding_profile) 28 | self.encoding_profile = result 29 | self.assertEquals(result.name, 'API Test Profile') 30 | self.assertEquals(result.video_stream_configs[0].default_stream_id, 1) 31 | self.assertEquals(result.video_stream_configs[0].bitrate, 512000) 32 | self.assertEquals(result.video_stream_configs[0].profile, 'Main') 33 | self.assertEquals(result.video_stream_configs[0].preset.lower(), 'premium') 34 | self.assertEquals(result.video_stream_configs[0].height, 480) 35 | self.assertEquals(result.video_stream_configs[0].width, 640) 36 | self.assertEquals(result.audio_stream_configs[0].default_stream_id, 0) 37 | self.assertEquals(result.audio_stream_configs[0].bitrate, 192000) 38 | self.assertEquals(result.rotation, 45) 39 | 40 | def tearDown(self): 41 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 42 | super(CreateEncodingProfileWithRotationTestCase, self).tearDown() 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_create_encoding_profile_sample_rate.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import EncodingProfile 5 | from bitcodin import AudioStreamConfig 6 | from bitcodin import VideoStreamConfig 7 | from bitcodin import create_encoding_profile 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class CreateEncodingProfileWithSpecificSampleRatesTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(CreateEncodingProfileWithSpecificSampleRatesTestCase, self).setUp() 15 | 16 | def runTest(self): 17 | audio_stream_config = AudioStreamConfig( 18 | default_stream_id=0, 19 | bitrate=192000, 20 | rate=48000 21 | ) 22 | video_stream_config = VideoStreamConfig( 23 | default_stream_id=1, 24 | bitrate=512000, 25 | profile='Main', 26 | preset='premium', 27 | height=480, 28 | width=640, 29 | rate=24 30 | ) 31 | encoding_profile = EncodingProfile( 32 | name='API Test Profile', 33 | video_stream_configs=[video_stream_config], 34 | audio_stream_configs=[audio_stream_config] 35 | ) 36 | 37 | result = create_encoding_profile(encoding_profile) 38 | self.encoding_profile = result 39 | self.assertEquals(result.name, 'API Test Profile') 40 | self.assertEquals(result.video_stream_configs[0].default_stream_id, 1) 41 | self.assertEquals(result.video_stream_configs[0].bitrate, 512000) 42 | self.assertEquals(result.video_stream_configs[0].profile, 'Main') 43 | self.assertEquals(result.video_stream_configs[0].preset.lower(), 'premium') 44 | self.assertEquals(result.video_stream_configs[0].height, 480) 45 | self.assertEquals(result.video_stream_configs[0].width, 640) 46 | self.assertEquals(result.audio_stream_configs[0].default_stream_id, 0) 47 | self.assertEquals(result.audio_stream_configs[0].bitrate, 192000) 48 | #self.assertEquals(result.video_stream_configs[0].rate, 24) 49 | #self.assertEquals(result.audio_stream_configs[0].rate, 48000) 50 | 51 | def tearDown(self): 52 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 53 | super(CreateEncodingProfileWithSpecificSampleRatesTestCase, self).tearDown() 54 | 55 | 56 | if __name__ == '__main__': 57 | unittest.main() 58 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_create_encoding_profile_segment_length.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import EncodingProfile 5 | from bitcodin import AudioStreamConfig 6 | from bitcodin import VideoStreamConfig 7 | from bitcodin import create_encoding_profile 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class CreateEncodingProfileWithSpecificSegmentLengthTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(CreateEncodingProfileWithSpecificSegmentLengthTestCase, self).setUp() 15 | 16 | def runTest(self): 17 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 18 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 19 | profile='Main', preset='premium', height=480, width=640) 20 | encoding_profile = EncodingProfile( 21 | name='API Test Profile', 22 | video_stream_configs=[video_stream_config], 23 | audio_stream_configs=[audio_stream_config], 24 | segment_length=2 25 | ) 26 | 27 | result = create_encoding_profile(encoding_profile) 28 | self.encoding_profile = result 29 | self.assertEquals(result.name, 'API Test Profile') 30 | self.assertEquals(result.video_stream_configs[0].default_stream_id, 1) 31 | self.assertEquals(result.video_stream_configs[0].bitrate, 512000) 32 | self.assertEquals(result.video_stream_configs[0].profile, 'Main') 33 | self.assertEquals(result.video_stream_configs[0].preset.lower(), 'premium') 34 | self.assertEquals(result.video_stream_configs[0].height, 480) 35 | self.assertEquals(result.video_stream_configs[0].width, 640) 36 | self.assertEquals(result.audio_stream_configs[0].default_stream_id, 0) 37 | self.assertEquals(result.audio_stream_configs[0].bitrate, 192000) 38 | self.assertEquals(result.segment_length, 2) 39 | 40 | def tearDown(self): 41 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 42 | super(CreateEncodingProfileWithSpecificSegmentLengthTestCase, self).tearDown() 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_create_encoding_profile_watermarked.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import EncodingProfile 5 | from bitcodin import AudioStreamConfig 6 | from bitcodin import VideoStreamConfig 7 | from bitcodin import create_encoding_profile 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import WatermarkConfig 10 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 11 | 12 | 13 | class CreateEncodingProfileWithWatermarkTestCase(BitcodinTestCase): 14 | def setUp(self): 15 | super(CreateEncodingProfileWithWatermarkTestCase, self).setUp() 16 | 17 | def runTest(self): 18 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 19 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 20 | profile='Main', preset='premium', height=480, width=640) 21 | 22 | watermark_config = WatermarkConfig( 23 | image_url='http://bitdash-a.akamaihd.net/webpages/bitcodin/images/bitcodin-bitmovin-logo-small.png', 24 | bottom=200, 25 | right=100 26 | ) 27 | 28 | encoding_profile = EncodingProfile( 29 | name='API Test Profile', 30 | video_stream_configs=[video_stream_config], 31 | audio_stream_configs=[audio_stream_config], 32 | watermark_config=watermark_config 33 | ) 34 | 35 | result = create_encoding_profile(encoding_profile) 36 | self.encoding_profile = result 37 | self.assertEquals(result.name, 'API Test Profile') 38 | self.assertEquals(result.video_stream_configs[0].default_stream_id, 1) 39 | self.assertEquals(result.video_stream_configs[0].bitrate, 512000) 40 | self.assertEquals(result.video_stream_configs[0].profile, 'Main') 41 | self.assertEquals(result.video_stream_configs[0].preset.lower(), 'premium') 42 | self.assertEquals(result.video_stream_configs[0].height, 480) 43 | self.assertEquals(result.video_stream_configs[0].width, 640) 44 | self.assertEquals(result.audio_stream_configs[0].default_stream_id, 0) 45 | self.assertEquals(result.audio_stream_configs[0].bitrate, 192000) 46 | self.assertEquals(result.watermark_config.image, 47 | 'http://bitdash-a.akamaihd.net/webpages/bitcodin/images/bitcodin-bitmovin-logo-small.png') 48 | self.assertEquals(result.watermark_config.bottom, 200) 49 | self.assertEquals(result.watermark_config.right, 100) 50 | 51 | def tearDown(self): 52 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 53 | super(CreateEncodingProfileWithWatermarkTestCase, self).tearDown() 54 | 55 | 56 | if __name__ == '__main__': 57 | unittest.main() 58 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_delete_encoding_profile.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import EncodingProfile 5 | from bitcodin import AudioStreamConfig 6 | from bitcodin import VideoStreamConfig 7 | from bitcodin import create_encoding_profile 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class DeleteEncodingProfileTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(DeleteEncodingProfileTestCase, self).setUp() 15 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 16 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 17 | profile='Main', preset='premium', height=480, width=640) 18 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 19 | self.encoding_profile = create_encoding_profile(encoding_profile) 20 | 21 | def runTest(self): 22 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 23 | 24 | def tearDown(self): 25 | super(DeleteEncodingProfileTestCase, self).tearDown() 26 | 27 | 28 | if __name__ == '__main__': 29 | unittest.main() 30 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_delete_non_existent_encoding_profile.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import delete_encoding_profile 5 | from bitcodin.exceptions import BitcodinNotFoundError 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class DeleteNonExistentEncodingProfileTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(DeleteNonExistentEncodingProfileTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | with self.assertRaises(BitcodinNotFoundError): 15 | delete_encoding_profile(0) 16 | 17 | def tearDown(self): 18 | super(DeleteNonExistentEncodingProfileTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_get_encoding_profile.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import get_encoding_profile 5 | from bitcodin import EncodingProfile 6 | from bitcodin import AudioStreamConfig 7 | from bitcodin import VideoStreamConfig 8 | from bitcodin import create_encoding_profile 9 | from bitcodin import delete_encoding_profile 10 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 11 | 12 | 13 | class GetEncodingProfileTestCase(BitcodinTestCase): 14 | def setUp(self): 15 | super(GetEncodingProfileTestCase, self).setUp() 16 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 17 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 18 | profile='Main', preset='premium', height=480, width=640) 19 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 20 | self.created_encoding_profile = create_encoding_profile(encoding_profile) 21 | 22 | def runTest(self): 23 | id = self.created_encoding_profile.encoding_profile_id 24 | encoding_profile = get_encoding_profile(id) 25 | self.assertEquals(self.created_encoding_profile.encoding_profile_id, encoding_profile.encoding_profile_id) 26 | self.assertEquals(self.created_encoding_profile.name, encoding_profile.name) 27 | self.assertEquals(self.created_encoding_profile.video_stream_configs[0].default_stream_id, encoding_profile.video_stream_configs[0].default_stream_id) 28 | self.assertEquals(self.created_encoding_profile.video_stream_configs[0].bitrate, encoding_profile.video_stream_configs[0].bitrate) 29 | self.assertEquals(self.created_encoding_profile.video_stream_configs[0].profile, encoding_profile.video_stream_configs[0].profile) 30 | self.assertEquals(self.created_encoding_profile.video_stream_configs[0].preset.lower(), encoding_profile.video_stream_configs[0].preset.lower()) 31 | self.assertEquals(self.created_encoding_profile.video_stream_configs[0].height, encoding_profile.video_stream_configs[0].height) 32 | self.assertEquals(self.created_encoding_profile.video_stream_configs[0].width, encoding_profile.video_stream_configs[0].width) 33 | self.assertEquals(self.created_encoding_profile.audio_stream_configs[0].default_stream_id, encoding_profile.audio_stream_configs[0].default_stream_id) 34 | self.assertEquals(self.created_encoding_profile.audio_stream_configs[0].bitrate, encoding_profile.audio_stream_configs[0].bitrate) 35 | 36 | def tearDown(self): 37 | delete_encoding_profile(self.created_encoding_profile.encoding_profile_id) 38 | super(GetEncodingProfileTestCase, self).tearDown() 39 | 40 | 41 | if __name__ == '__main__': 42 | unittest.main() 43 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_get_list_encoding_profiles.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import AudioStreamConfig 5 | from bitcodin import VideoStreamConfig 6 | from bitcodin import EncodingProfile 7 | from bitcodin import create_encoding_profile 8 | from bitcodin import list_encoding_profiles 9 | from bitcodin import delete_encoding_profile 10 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 11 | 12 | 13 | class GetEncodingProfileListTestCase(BitcodinTestCase): 14 | def setUp(self): 15 | super(GetEncodingProfileListTestCase, self).setUp() 16 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 17 | video_stream_config = VideoStreamConfig(default_stream_id=1, bitrate=512000, 18 | profile='Main', preset='premium', height=480, width=640) 19 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 20 | self.encoding_profile = create_encoding_profile(encoding_profile) 21 | 22 | def runTest(self): 23 | encoding_profiles = list_encoding_profiles() 24 | encoding_profile_found = False 25 | for encoding_profile in encoding_profiles: 26 | if self.encoding_profile.encoding_profile_id == encoding_profile.encoding_profile_id: 27 | encoding_profile_found = True 28 | break 29 | self.assertEquals(encoding_profile_found, True) 30 | 31 | def tearDown(self): 32 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 33 | super(GetEncodingProfileListTestCase, self).tearDown() 34 | 35 | 36 | if __name__ == '__main__': 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /bitcodin/test/encodingprofile/testcase_get_non_existent_encoding_profile.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import get_encoding_profile 5 | from bitcodin.exceptions import BitcodinNotFoundError 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class GetNonExistentEncodingProfileTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(GetNonExistentEncodingProfileTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | with self.assertRaises(BitcodinNotFoundError): 15 | encoding_profile = get_encoding_profile(0) 16 | 17 | def tearDown(self): 18 | super(GetNonExistentEncodingProfileTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/test/http/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | from unittest import TestSuite 4 | 5 | from .testcase_get_undefined import HttpGetUndefinedTestCase 6 | from .testcase_post_undefined import HttpPostUndefinedTestCase 7 | from .testcase_delete_undefined import HttpDeleteUndefinedTestCase 8 | 9 | 10 | def get_test_suite(): 11 | test_suite = TestSuite() 12 | test_suite.addTest(HttpGetUndefinedTestCase()) 13 | test_suite.addTest(HttpPostUndefinedTestCase()) 14 | test_suite.addTest(HttpDeleteUndefinedTestCase()) 15 | return test_suite 16 | -------------------------------------------------------------------------------- /bitcodin/test/http/testcase_delete_undefined.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import get_api_base 5 | from bitcodin.rest import RestClient 6 | from bitcodin.api import create_headers 7 | from bitcodin.exceptions import BitcodinNotFoundError 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class HttpDeleteUndefinedTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(HttpDeleteUndefinedTestCase, self).setUp() 14 | 15 | def runTest(self): 16 | headers = create_headers() 17 | url = get_api_base() + '/MY_SUPER_FANCY_UNDEFINED_URL/' 18 | with self.assertRaises(BitcodinNotFoundError): 19 | response = RestClient.delete(url=url, headers=headers) 20 | 21 | def tearDown(self): 22 | super(HttpDeleteUndefinedTestCase, self).tearDown() 23 | 24 | 25 | if __name__ == '__main__': 26 | unittest.main() 27 | -------------------------------------------------------------------------------- /bitcodin/test/http/testcase_get_undefined.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import get_api_base 5 | from bitcodin.rest import RestClient 6 | from bitcodin.api import create_headers 7 | from bitcodin.exceptions import BitcodinNotFoundError 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class HttpGetUndefinedTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(HttpGetUndefinedTestCase, self).setUp() 14 | 15 | def runTest(self): 16 | headers = create_headers() 17 | url = get_api_base() + '/MY_SUPER_FANCY_UNDEFINED_URL/' 18 | with self.assertRaises(BitcodinNotFoundError): 19 | response = RestClient.get(url=url, headers=headers) 20 | 21 | def tearDown(self): 22 | super(HttpGetUndefinedTestCase, self).tearDown() 23 | 24 | 25 | if __name__ == '__main__': 26 | unittest.main() 27 | -------------------------------------------------------------------------------- /bitcodin/test/http/testcase_post_undefined.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import get_api_base 5 | from bitcodin.rest import RestClient 6 | from bitcodin.api import create_headers 7 | from bitcodin.exceptions import BitcodinBadRequestError 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class HttpPostUndefinedTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(HttpPostUndefinedTestCase, self).setUp() 14 | 15 | def runTest(self): 16 | headers = create_headers() 17 | url = get_api_base() + '/MY_SUPER_FANCY_UNDEFINED_URL/' 18 | with self.assertRaises(BitcodinBadRequestError): 19 | response = RestClient.post(url=url, headers=headers) 20 | 21 | def tearDown(self): 22 | super(HttpPostUndefinedTestCase, self).tearDown() 23 | 24 | 25 | if __name__ == '__main__': 26 | unittest.main() 27 | -------------------------------------------------------------------------------- /bitcodin/test/input/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | from unittest import TestSuite 4 | 5 | from .testcase_create_input_incomplete_data import CreateInputIncompleteDataTestCase 6 | from .testcase_create_input_invalid_data import CreateInputInvalidDataTestCase 7 | from .testcase_create_input import CreateInputTestCase 8 | from .testcase_get_input import GetInputTestCase 9 | from .testcase_get_non_existent_input import GetNonExistentInputTestCase 10 | from .testcase_get_list_inputs import GetInputListTestCase 11 | from .testcase_delete_non_existent_input import DeleteNonExistentInputTestCase 12 | from .testcase_delete_input import DeleteInputTestCase 13 | from .testcase_analyze_non_existent_input import AnalyzeNonExistentInputTestCase 14 | from .testcase_analyze_input import AnalyzeInputTestCase 15 | from .testcase_create_s3_input import CreateS3InputTestCase 16 | from .testcase_create_azure_input import CreateAzureInputTestCase 17 | 18 | 19 | def get_test_suite(): 20 | test_suite = TestSuite() 21 | test_suite.addTest(CreateInputIncompleteDataTestCase()) 22 | test_suite.addTest(CreateInputInvalidDataTestCase()) 23 | test_suite.addTest(CreateInputTestCase()) 24 | test_suite.addTest(GetInputTestCase()) 25 | test_suite.addTest(GetNonExistentInputTestCase()) 26 | # test_suite.addTest(GetInputListTestCase()) 27 | test_suite.addTest(DeleteNonExistentInputTestCase()) 28 | test_suite.addTest(DeleteInputTestCase()) 29 | test_suite.addTest(AnalyzeNonExistentInputTestCase()) 30 | test_suite.addTest(AnalyzeInputTestCase()) 31 | test_suite.addTest(CreateS3InputTestCase()) 32 | test_suite.addTest(CreateAzureInputTestCase()) 33 | return test_suite 34 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_analyze_non_existent_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import analyze_input 5 | from bitcodin.exceptions import BitcodinNotFoundError 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class AnalyzeNonExistentInputTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(AnalyzeNonExistentInputTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | with self.assertRaises(BitcodinNotFoundError): 15 | encoding_profile = analyze_input(0) 16 | 17 | def tearDown(self): 18 | super(AnalyzeNonExistentInputTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_create_azure_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_input 5 | from bitcodin import delete_input 6 | from bitcodin import AzureInput 7 | from bitcodin.test.settings import azure_input_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateAzureInputTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(CreateAzureInputTestCase, self).setUp() 14 | 15 | def runTest(self): 16 | input = AzureInput( 17 | account_name=azure_input_config.get('accountName'), 18 | account_key=azure_input_config.get('accountKey'), 19 | container=azure_input_config.get('container'), 20 | url=azure_input_config.get('url') 21 | ) 22 | 23 | self.input = create_input(input) 24 | 25 | self.assertEquals(self.input.filename, input.url) 26 | self.assertEquals(self.input.status, 'CREATED') 27 | 28 | def tearDown(self): 29 | delete_input(self.input.input_id) 30 | super(CreateAzureInputTestCase, self).tearDown() 31 | 32 | 33 | if __name__ == '__main__': 34 | unittest.main() 35 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_create_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_input 5 | from bitcodin import delete_input 6 | from bitcodin import Input 7 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 8 | 9 | 10 | class CreateInputTestCase(BitcodinTestCase): 11 | def setUp(self): 12 | super(CreateInputTestCase, self).setUp() 13 | self.inputUrl = 'http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv' 14 | 15 | def runTest(self): 16 | input = Input(self.inputUrl) 17 | self.input = create_input(input) 18 | self.assertEquals(self.input.url, input.url) 19 | self.assertEquals(self.input.status, 'CREATED') 20 | 21 | def tearDown(self): 22 | delete_input(self.input.input_id) 23 | super(CreateInputTestCase, self).tearDown() 24 | 25 | 26 | if __name__ == '__main__': 27 | unittest.main() 28 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_create_input_async.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | 3 | import unittest 4 | from bitcodin import create_input, get_input, get_async_input_status 5 | from bitcodin import delete_input 6 | from bitcodin import S3Input 7 | from bitcodin.test.settings import s3_input_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateS3InputTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(CreateS3InputTestCase, self).setUp() 14 | 15 | def runTest(self): 16 | input = S3Input( 17 | access_key=s3_input_config.get('access_key'), 18 | secret_key=s3_input_config.get('secret_key'), 19 | host=s3_input_config.get('host'), 20 | bucket=s3_input_config.get('bucket'), 21 | region=s3_input_config.get('region'), 22 | object_key=s3_input_config.get('object_key') 23 | ) 24 | 25 | self.input = create_input(input, True) 26 | 27 | async_input_status = get_async_input_status(self.input.input_id) 28 | while async_input_status.status != 'CREATED': 29 | async_input_status = get_async_input_status(async_input_status.input_id) 30 | self.assertNotEqual(async_input_status.status, 'ERROR') 31 | print(async_input_status.to_json()) 32 | sleep(5) 33 | 34 | self.input = get_input(self.input.input_id) 35 | self.assertEquals(self.input.host, input.host) 36 | self.assertEquals(self.input.bucket, input.bucket) 37 | self.assertEquals(self.input.region, input.region) 38 | self.assertEquals(self.input.status, 'CREATED') 39 | 40 | def tearDown(self): 41 | delete_input(self.input.input_id) 42 | super(CreateS3InputTestCase, self).tearDown() 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_create_input_incomplete_data.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_input 5 | from bitcodin import Input 6 | from bitcodin.exceptions import BitcodinBadRequestError 7 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 8 | 9 | 10 | class CreateInputIncompleteDataTestCase(BitcodinTestCase): 11 | def setUp(self): 12 | super(CreateInputIncompleteDataTestCase, self).setUp() 13 | self.inputUrl = '' 14 | 15 | def runTest(self): 16 | input = Input(self.inputUrl) 17 | with self.assertRaises(BitcodinBadRequestError): 18 | result = create_input(input) 19 | 20 | def tearDown(self): 21 | super(CreateInputIncompleteDataTestCase, self).tearDown() 22 | 23 | 24 | if __name__ == '__main__': 25 | unittest.main() 26 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_create_input_invalid_data.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_input 5 | from bitcodin import Input 6 | from bitcodin.exceptions import BitcodinBadRequestError 7 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 8 | 9 | 10 | class CreateInputInvalidDataTestCase(BitcodinTestCase): 11 | def setUp(self): 12 | super(CreateInputInvalidDataTestCase, self).setUp() 13 | self.inputUrl = 'http://myfancyurlwhichdoes.not.exist.com/mydest/mysupervideo.mp4' 14 | 15 | def runTest(self): 16 | input = Input(self.inputUrl) 17 | with self.assertRaises(BitcodinBadRequestError): 18 | result = create_input(input) 19 | 20 | def tearDown(self): 21 | super(CreateInputInvalidDataTestCase, self).tearDown() 22 | 23 | 24 | if __name__ == '__main__': 25 | unittest.main() 26 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_create_s3_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_input 5 | from bitcodin import delete_input 6 | from bitcodin import S3Input 7 | from bitcodin.test.settings import s3_input_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateS3InputTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(CreateS3InputTestCase, self).setUp() 14 | 15 | def runTest(self): 16 | input = S3Input( 17 | access_key=s3_input_config.get('access_key'), 18 | secret_key=s3_input_config.get('secret_key'), 19 | host=s3_input_config.get('host'), 20 | bucket=s3_input_config.get('bucket'), 21 | region=s3_input_config.get('region'), 22 | object_key=s3_input_config.get('object_key') 23 | ) 24 | 25 | self.input = create_input(input) 26 | 27 | self.assertEquals(self.input.host, input.host) 28 | self.assertEquals(self.input.bucket, input.bucket) 29 | self.assertEquals(self.input.region, input.region) 30 | self.assertEquals(self.input.status, 'CREATED') 31 | 32 | def tearDown(self): 33 | delete_input(self.input.input_id) 34 | super(CreateS3InputTestCase, self).tearDown() 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_delete_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import Input 5 | from bitcodin import create_input 6 | from bitcodin import delete_input 7 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 8 | 9 | 10 | class DeleteInputTestCase(BitcodinTestCase): 11 | def setUp(self): 12 | super(DeleteInputTestCase, self).setUp() 13 | input_url = 'http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv' 14 | input = Input(input_url) 15 | self.input = create_input(input) 16 | 17 | def runTest(self): 18 | delete_input(self.input.input_id) 19 | 20 | def tearDown(self): 21 | super(DeleteInputTestCase, self).tearDown() 22 | 23 | 24 | if __name__ == '__main__': 25 | unittest.main() 26 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_delete_non_existent_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import delete_input 5 | from bitcodin.exceptions import BitcodinNotFoundError 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class DeleteNonExistentInputTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(DeleteNonExistentInputTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | with self.assertRaises(BitcodinNotFoundError): 15 | delete_input(0) 16 | 17 | def tearDown(self): 18 | super(DeleteNonExistentInputTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_get_list_inputs.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_input 5 | from bitcodin import delete_input 6 | from bitcodin import Input 7 | from bitcodin import list_inputs 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class GetInputListTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(GetInputListTestCase, self).setUp() 14 | input_url = 'http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv' 15 | input = Input(input_url) 16 | self.input = create_input(input) 17 | 18 | def runTest(self): 19 | inputs = list_inputs() 20 | input_found = False 21 | for input in inputs: 22 | if self.input.input_id == input.input_id: 23 | input_found = True 24 | break 25 | self.assertEquals(input_found, True) 26 | 27 | def tearDown(self): 28 | delete_input(self.input.input_id) 29 | super(GetInputListTestCase, self).tearDown() 30 | 31 | 32 | if __name__ == '__main__': 33 | unittest.main() 34 | -------------------------------------------------------------------------------- /bitcodin/test/input/testcase_get_non_existent_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import get_input 5 | from bitcodin.exceptions import BitcodinNotFoundError 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class GetNonExistentInputTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(GetNonExistentInputTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | with self.assertRaises(BitcodinNotFoundError): 15 | encoding_profile = get_input(0) 16 | 17 | def tearDown(self): 18 | super(GetNonExistentInputTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_autotransfer_job_gcs.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from time import sleep, time 5 | from bitcodin import create_job 6 | from bitcodin import create_input 7 | from bitcodin import create_encoding_profile 8 | from bitcodin import delete_input 9 | from bitcodin import delete_encoding_profile 10 | from bitcodin import transfer_job 11 | from bitcodin import create_output 12 | from bitcodin import delete_output 13 | from bitcodin import get_job_status 14 | from bitcodin import Job 15 | from bitcodin import Input 16 | from bitcodin import AudioStreamConfig 17 | from bitcodin import VideoStreamConfig 18 | from bitcodin import EncodingProfile 19 | from bitcodin import GCSOutput 20 | from bitcodin.exceptions import BitcodinError 21 | from bitcodin.test.settings import gcs_output_config 22 | from bitcodin.test.config import test_video_url 23 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 24 | 25 | 26 | class AutoTransferJobToGCSTestCase(BitcodinTestCase): 27 | def setUp(self): 28 | super(AutoTransferJobToGCSTestCase, self).setUp() 29 | self.maxDiff = None 30 | 31 | input_url = test_video_url 32 | input = Input(input_url) 33 | self.input = create_input(input) 34 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 35 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 36 | profile='Main', preset='premium', height=480, width=640) 37 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 38 | self.encoding_profile = create_encoding_profile(encoding_profile) 39 | self.manifests = ['m3u8', 'mpd'] 40 | output = GCSOutput( 41 | name='Python Test Output', 42 | access_key=gcs_output_config.get('accessKey'), 43 | secret_key=gcs_output_config.get('secretKey'), 44 | bucket=gcs_output_config.get('bucket'), 45 | prefix=gcs_output_config.get('prefix'), 46 | make_public=False 47 | ) 48 | self.output = create_output(output) 49 | 50 | def runTest(self): 51 | job = Job( 52 | input_id=self.input.input_id, 53 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 54 | manifest_types=self.manifests, 55 | output_id=self.output.output_id 56 | ) 57 | self.job = create_job(job) 58 | self.wait_until_job_finished(self.job.job_id) 59 | 60 | def tearDown(self): 61 | delete_input(self.input.input_id) 62 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 63 | super(AutoTransferJobToGCSTestCase, self).tearDown() 64 | 65 | 66 | if __name__ == '__main__': 67 | unittest.main() 68 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.config import test_video_url 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobTestCase, self).setUp() 21 | input_url = test_video_url 22 | input = Input(input_url) 23 | self.input = create_input(input) 24 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 25 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 26 | profile='Main', preset='premium', height=480, width=640) 27 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 28 | self.encoding_profile = create_encoding_profile(encoding_profile) 29 | self.manifests = ['m3u8', 'mpd'] 30 | 31 | def runTest(self): 32 | job = Job( 33 | input_id=self.input.input_id, 34 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 35 | manifest_types=self.manifests 36 | ) 37 | self.job = create_job(job) 38 | self.assertEquals(self.job.input.input_id, job.inputId) 39 | self.assertEquals(self.job.input.url, self.input.url) 40 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 41 | self.wait_until_job_finished(self.job.job_id) 42 | 43 | def tearDown(self): 44 | delete_input(self.input.input_id) 45 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 46 | super(CreateJobTestCase, self).tearDown() 47 | 48 | 49 | if __name__ == '__main__': 50 | unittest.main() 51 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_azure_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import AzureInput 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.settings import azure_input_config 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobAzureInputTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobAzureInputTestCase, self).setUp() 21 | 22 | input = AzureInput( 23 | account_name=azure_input_config.get('accountName'), 24 | account_key=azure_input_config.get('accountKey'), 25 | container=azure_input_config.get('container'), 26 | url=azure_input_config.get('url') 27 | ) 28 | 29 | self.input = create_input(input) 30 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 31 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 32 | profile='Main', preset='premium', height=480, width=640) 33 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 34 | self.encoding_profile = create_encoding_profile(encoding_profile) 35 | self.manifests = ['m3u8', 'mpd'] 36 | 37 | def runTest(self): 38 | job = Job( 39 | input_id=self.input.input_id, 40 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 41 | manifest_types=self.manifests, 42 | speed='standard' 43 | ) 44 | self.job = create_job(job) 45 | self.assertEquals(self.job.input.input_id, job.inputId) 46 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 47 | self.wait_until_job_finished(self.job.job_id) 48 | 49 | def tearDown(self): 50 | delete_input(self.input.input_id) 51 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 52 | super(CreateJobAzureInputTestCase, self).tearDown() 53 | 54 | 55 | if __name__ == '__main__': 56 | unittest.main() 57 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_deinterlace.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.config import test_video_url 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobWithDeinterlacing(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobWithDeinterlacing, self).setUp() 21 | input_url = test_video_url 22 | input = Input(input_url) 23 | self.input = create_input(input) 24 | audio_stream_config = AudioStreamConfig( 25 | default_stream_id=0, 26 | bitrate=192000 27 | ) 28 | video_stream_config = VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=512000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=640 35 | ) 36 | 37 | encoding_profile = EncodingProfile( 38 | name='API Test Profile', 39 | video_stream_configs=[video_stream_config], 40 | audio_stream_configs=[audio_stream_config] 41 | ) 42 | self.encoding_profile = create_encoding_profile(encoding_profile) 43 | self.manifests = ['m3u8', 'mpd'] 44 | 45 | def runTest(self): 46 | job = Job( 47 | input_id=self.input.input_id, 48 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 49 | manifest_types=self.manifests, 50 | speed='standard', 51 | deinterlace=True 52 | ) 53 | self.job = create_job(job) 54 | self.assertEquals(self.job.input.input_id, job.inputId) 55 | self.assertEquals(self.job.input.url, self.input.url) 56 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 57 | self.assertEquals(self.job.deinterlace, job.deinterlace) 58 | self.wait_until_job_finished(self.job.job_id) 59 | 60 | def tearDown(self): 61 | delete_input(self.input.input_id) 62 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 63 | super(CreateJobWithDeinterlacing, self).tearDown() 64 | 65 | 66 | if __name__ == '__main__': 67 | unittest.main() 68 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_hls_encryption.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin import HLSEncryptionConfig 15 | from bitcodin.test.config import test_video_url 16 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 17 | 18 | 19 | class CreateJobHLSEncryptionTestCase(BitcodinTestCase): 20 | def setUp(self): 21 | super(CreateJobHLSEncryptionTestCase, self).setUp() 22 | input_url = test_video_url 23 | input = Input(input_url) 24 | self.input = create_input(input) 25 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 26 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 27 | profile='Main', preset='premium', height=480, width=640) 28 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 29 | self.encoding_profile = create_encoding_profile(encoding_profile) 30 | self.manifests = ['m3u8', 'mpd'] 31 | self.hls_encryption_config = HLSEncryptionConfig( 32 | key='cab5b529ae28d5cc5e3e7bc3fd4a544d', 33 | method='SAMPLE-AES', 34 | iv='08eecef4b026deec395234d94218273d' 35 | ) 36 | 37 | def runTest(self): 38 | job = Job( 39 | input_id=self.input.input_id, 40 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 41 | manifest_types=self.manifests, 42 | speed='standard', 43 | hls_encryption_config=self.hls_encryption_config 44 | ) 45 | self.job = create_job(job) 46 | self.assertEquals(self.job.input.input_id, job.inputId) 47 | self.assertEquals(self.job.input.url, self.input.url) 48 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 49 | self.wait_until_job_finished(self.job.job_id) 50 | 51 | def tearDown(self): 52 | delete_input(self.input.input_id) 53 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 54 | super(CreateJobHLSEncryptionTestCase, self).tearDown() 55 | 56 | 57 | if __name__ == '__main__': 58 | unittest.main() 59 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_incomplete_data.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import Job 8 | from bitcodin import Input 9 | from bitcodin import AudioStreamConfig 10 | from bitcodin import VideoStreamConfig 11 | from bitcodin import EncodingProfile 12 | from bitcodin.exceptions import BitcodinBadRequestError 13 | from bitcodin.test.config import test_video_url 14 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 15 | 16 | 17 | class CreateJobIncompleteDataTestCase(BitcodinTestCase): 18 | def setUp(self): 19 | super(CreateJobIncompleteDataTestCase, self).setUp() 20 | input_url = test_video_url 21 | input = Input(input_url) 22 | self.input = create_input(input) 23 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 24 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 25 | profile='Main', preset='premium', height=480, width=640) 26 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 27 | self.encoding_profile = create_encoding_profile(encoding_profile) 28 | 29 | def runTest(self): 30 | job = Job( 31 | input_id=self.input.input_id, 32 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 33 | manifest_types=[] 34 | ) 35 | with self.assertRaises(BitcodinBadRequestError): 36 | result = create_job(job) 37 | 38 | def tearDown(self): 39 | super(CreateJobIncompleteDataTestCase, self).tearDown() 40 | 41 | 42 | if __name__ == '__main__': 43 | unittest.main() 44 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_invalid_data.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import Job 8 | from bitcodin import Input 9 | from bitcodin import AudioStreamConfig 10 | from bitcodin import VideoStreamConfig 11 | from bitcodin import EncodingProfile 12 | from bitcodin.exceptions import BitcodinBadRequestError 13 | from bitcodin.test.config import test_video_url 14 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 15 | 16 | 17 | class CreateJobInvalidDataTestCase(BitcodinTestCase): 18 | def setUp(self): 19 | super(CreateJobInvalidDataTestCase, self).setUp() 20 | input_url = test_video_url 21 | input = Input(input_url) 22 | self.input = create_input(input) 23 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 24 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 25 | profile='Main', preset='premium', height=480, width=640) 26 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 27 | self.encoding_profile = create_encoding_profile(encoding_profile) 28 | 29 | def runTest(self): 30 | job = Job( 31 | input_id=self.input.input_id, 32 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 33 | manifest_types=['m3u8', 'invalid'] 34 | ) 35 | with self.assertRaises(BitcodinBadRequestError): 36 | result = create_job(job) 37 | 38 | def tearDown(self): 39 | super(CreateJobInvalidDataTestCase, self).tearDown() 40 | 41 | 42 | if __name__ == '__main__': 43 | unittest.main() 44 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_keep_aspect_ratio.py: -------------------------------------------------------------------------------- 1 | __author__ = 'David Moser ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.config import test_video_url 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobKeepAspectRatioTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobKeepAspectRatioTestCase, self).setUp() 21 | input_url = test_video_url 22 | input = Input(input_url) 23 | self.input = create_input(input) 24 | video_configs = list() 25 | 26 | video_configs.append(VideoStreamConfig( 27 | default_stream_id=0, 28 | bitrate=4800000, 29 | profile='Main', 30 | preset='premium', 31 | height=600, 32 | width=1920 33 | )) 34 | video_configs.append(VideoStreamConfig( 35 | default_stream_id=0, 36 | bitrate=2400000, 37 | profile='Main', 38 | preset='premium', 39 | width=1024 40 | )) 41 | video_configs.append(VideoStreamConfig( 42 | default_stream_id=0, 43 | bitrate=1200000, 44 | profile='Main', 45 | preset='premium', 46 | height=720 47 | )) 48 | 49 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 50 | 51 | encoding_profile = EncodingProfile('API Test Profile', video_configs, [audio_stream_config]) 52 | self.encoding_profile = create_encoding_profile(encoding_profile) 53 | self.manifests = ['m3u8', 'mpd'] 54 | 55 | def runTest(self): 56 | job = Job( 57 | input_id=self.input.input_id, 58 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 59 | manifest_types=self.manifests 60 | ) 61 | self.job = create_job(job) 62 | self.assertEquals(self.job.input.input_id, job.inputId) 63 | self.assertEquals(self.job.input.url, self.input.url) 64 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 65 | self.wait_until_job_finished(self.job.job_id) 66 | 67 | def tearDown(self): 68 | delete_input(self.input.input_id) 69 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 70 | super(CreateJobKeepAspectRatioTestCase, self).tearDown() 71 | 72 | 73 | if __name__ == '__main__': 74 | unittest.main() 75 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_merge_audio_channels.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 6 | 7 | 8 | class CreateJobTestCase(BitcodinTestCase): 9 | def setUp(self): 10 | super(CreateJobTestCase, self).setUp() 11 | input_url = 'http://bitbucketireland.s3.amazonaws.com/at_test/mono_streams.mkv' 12 | input = bitcodin.Input(input_url) 13 | self.input = bitcodin.create_input(input) 14 | 15 | audio_configs = [ 16 | bitcodin.AudioStreamConfig( 17 | default_stream_id=0, 18 | bitrate=192000 19 | ) 20 | ] 21 | 22 | video_stream_config = [ 23 | bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=512000, 26 | profile='Main', 27 | preset='premium', 28 | height=480, 29 | width=640 30 | ) 31 | ] 32 | 33 | encoding_profile = bitcodin.EncodingProfile('API Merge Audio Multi Profile', 34 | video_stream_config, 35 | audio_configs) 36 | 37 | self.encoding_profile = bitcodin.create_encoding_profile(encoding_profile) 38 | self.manifests = ['m3u8', 'mpd'] 39 | 40 | merge_audio_channel_config = bitcodin.MergeAudioChannelConfig([1, 2, 3, 4, 5, 6]) 41 | 42 | self.merge_audio_channel_configs = [merge_audio_channel_config] 43 | 44 | audio_meta_data = bitcodin.AudioMetaData(0, 'en', 'All audio channels merged') 45 | 46 | self.audio_meta_data = [audio_meta_data] 47 | 48 | def runTest(self): 49 | job = bitcodin.Job( 50 | input_id=self.input.input_id, 51 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 52 | manifest_types=self.manifests, 53 | speed='standard', 54 | merge_audio_channel_configs=self.merge_audio_channel_configs, 55 | audio_meta_data=self.audio_meta_data 56 | ) 57 | self.job = bitcodin.create_job(job) 58 | self.assertEquals(self.job.input.input_id, job.inputId) 59 | self.assertEquals(self.job.input.url, self.input.url) 60 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 61 | self.wait_until_job_finished(self.job.job_id) 62 | 63 | def tearDown(self): 64 | bitcodin.delete_input(self.input.input_id) 65 | bitcodin.delete_encoding_profile(self.encoding_profile.encoding_profile_id) 66 | super(CreateJobTestCase, self).tearDown() 67 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_mp3_audio_only.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | 3 | __author__ = 'David Moser ' 4 | 5 | import unittest 6 | from bitcodin import create_job, get_job 7 | from bitcodin import create_input 8 | from bitcodin import create_encoding_profile 9 | from bitcodin import delete_input 10 | from bitcodin import delete_encoding_profile 11 | from bitcodin import Job 12 | from bitcodin import Input 13 | from bitcodin import AudioStreamConfig 14 | from bitcodin import EncodingProfile 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobAudioOnlyTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobAudioOnlyTestCase, self).setUp() 21 | input_url = "http://bitbucketireland.s3.amazonaws.com/audiosample.mp3" 22 | input = Input(input_url) 23 | self.input = create_input(input) 24 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 25 | encoding_profile = EncodingProfile('Audio Only Test Profile', [], [audio_stream_config]) 26 | self.encoding_profile = create_encoding_profile(encoding_profile) 27 | self.manifests = ['m3u8', 'mpd'] 28 | 29 | def runTest(self): 30 | job = Job( 31 | input_id=self.input.input_id, 32 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 33 | manifest_types=self.manifests, 34 | speed='standard' 35 | ) 36 | self.job = create_job(job) 37 | self.assertEquals(self.job.input.input_id, job.inputId) 38 | self.assertEquals(self.job.input.url, self.input.url) 39 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 40 | self.wait_until_job_finished(self.job.job_id) 41 | 42 | def tearDown(self): 43 | delete_input(self.input.input_id) 44 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 45 | super(CreateJobAudioOnlyTestCase, self).tearDown() 46 | 47 | 48 | if __name__ == '__main__': 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_playready_drm_invalid.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin import DrmConfig 15 | from bitcodin import WidevineDrmConfig 16 | from bitcodin import PlayreadyDrmConfig 17 | from bitcodin.exceptions import BitcodinBadRequestError 18 | from bitcodin.test.config import test_video_url 19 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 20 | 21 | 22 | class CreateJobPlayreadyDrmInvalidConfigTestCase(BitcodinTestCase): 23 | def setUp(self): 24 | super(CreateJobPlayreadyDrmInvalidConfigTestCase, self).setUp() 25 | input_url = test_video_url 26 | input = Input(input_url) 27 | self.input = create_input(input) 28 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 29 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 30 | profile='Main', preset='premium', height=480, width=640) 31 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 32 | self.encoding_profile = create_encoding_profile(encoding_profile) 33 | self.manifests = ['m3u8', 'mpd'] 34 | self.drm_config = PlayreadyDrmConfig( 35 | k_id=None, 36 | key=None, 37 | key_seed=None, 38 | la_url=None, 39 | lui_url=None, 40 | ds_id=None, 41 | custom_attributes=None, 42 | method='mpeg_cenc' 43 | ) 44 | 45 | def runTest(self): 46 | job = Job( 47 | input_id=self.input.input_id, 48 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 49 | manifest_types=self.manifests, 50 | speed='standard', 51 | drm_config=self.drm_config 52 | ) 53 | with self.assertRaises(BitcodinBadRequestError): 54 | self.job = create_job(job) 55 | 56 | def tearDown(self): 57 | delete_input(self.input.input_id) 58 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 59 | super(CreateJobPlayreadyDrmInvalidConfigTestCase, self).tearDown() 60 | 61 | 62 | if __name__ == '__main__': 63 | unittest.main() 64 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_playready_widevine_drm_invalid.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin import PlayreadyWidevineCombinedDrmConfig 15 | from bitcodin.exceptions import BitcodinBadRequestError 16 | from bitcodin.test.config import test_video_url 17 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 18 | 19 | 20 | class CreateJobPlayreadyWidevineDrmInvalidConfigTestCase(BitcodinTestCase): 21 | def setUp(self): 22 | super(CreateJobPlayreadyWidevineDrmInvalidConfigTestCase, self).setUp() 23 | input_url = test_video_url 24 | input = Input(input_url) 25 | self.input = create_input(input) 26 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 27 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 28 | profile='Main', preset='premium', height=480, width=640) 29 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 30 | self.encoding_profile = create_encoding_profile(encoding_profile) 31 | self.manifests = ['m3u8', 'mpd'] 32 | self.drm_config = PlayreadyWidevineCombinedDrmConfig( 33 | key=None, 34 | pssh=None, 35 | kid=None, 36 | la_url=None, 37 | lui_url=None, 38 | ds_id=None, 39 | custom_attributes=None, 40 | method=None 41 | ) 42 | 43 | def runTest(self): 44 | job = Job( 45 | input_id=self.input.input_id, 46 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 47 | manifest_types=self.manifests, 48 | speed='standard', 49 | drm_config=self.drm_config 50 | ) 51 | with self.assertRaises(BitcodinBadRequestError): 52 | self.job = create_job(job) 53 | 54 | def tearDown(self): 55 | delete_input(self.input.input_id) 56 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 57 | super(CreateJobPlayreadyWidevineDrmInvalidConfigTestCase, self).tearDown() 58 | 59 | 60 | if __name__ == '__main__': 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_rotation.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.config import test_video_url 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobWithRotationTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobWithRotationTestCase, self).setUp() 21 | input_url = test_video_url 22 | input = Input(input_url) 23 | self.input = create_input(input) 24 | audio_stream_config = AudioStreamConfig( 25 | default_stream_id=0, 26 | bitrate=192000 27 | ) 28 | video_stream_config = VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=512000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=640 35 | ) 36 | encoding_profile = EncodingProfile( 37 | name='API Test Profile', 38 | video_stream_configs=[video_stream_config], 39 | audio_stream_configs=[audio_stream_config], 40 | rotation=45 41 | ) 42 | self.encoding_profile = create_encoding_profile(encoding_profile) 43 | self.manifests = ['m3u8', 'mpd'] 44 | 45 | def runTest(self): 46 | job = Job( 47 | input_id=self.input.input_id, 48 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 49 | manifest_types=self.manifests, 50 | speed='standard' 51 | ) 52 | self.job = create_job(job) 53 | self.assertEquals(self.job.input.input_id, job.inputId) 54 | self.assertEquals(self.job.input.url, self.input.url) 55 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 56 | self.wait_until_job_finished(self.job.job_id) 57 | 58 | def tearDown(self): 59 | delete_input(self.input.input_id) 60 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 61 | super(CreateJobWithRotationTestCase, self).tearDown() 62 | 63 | 64 | if __name__ == '__main__': 65 | unittest.main() 66 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_s3_input.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import S3Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.settings import s3_input_config 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobS3InputTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobS3InputTestCase, self).setUp() 21 | 22 | input = S3Input( 23 | access_key=s3_input_config.get('access_key'), 24 | secret_key=s3_input_config.get('secret_key'), 25 | host=s3_input_config.get('host'), 26 | bucket=s3_input_config.get('bucket'), 27 | region=s3_input_config.get('region'), 28 | object_key=s3_input_config.get('object_key') 29 | ) 30 | 31 | self.input = create_input(input) 32 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 33 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 34 | profile='Main', preset='premium', height=480, width=640) 35 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 36 | self.encoding_profile = create_encoding_profile(encoding_profile) 37 | self.manifests = ['m3u8', 'mpd'] 38 | 39 | def runTest(self): 40 | job = Job( 41 | input_id=self.input.input_id, 42 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 43 | manifest_types=self.manifests, 44 | speed='standard' 45 | ) 46 | self.job = create_job(job) 47 | self.assertEquals(self.job.input.input_id, job.inputId) 48 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 49 | self.wait_until_job_finished(self.job.job_id) 50 | 51 | def tearDown(self): 52 | delete_input(self.input.input_id) 53 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 54 | super(CreateJobS3InputTestCase, self).tearDown() 55 | 56 | 57 | if __name__ == '__main__': 58 | unittest.main() 59 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_skip_analysis.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from bitcodin import create_job 3 | from bitcodin import create_input 4 | from bitcodin import create_encoding_profile 5 | from bitcodin import delete_input 6 | from bitcodin import delete_encoding_profile 7 | from bitcodin import Job 8 | from bitcodin import Input 9 | from bitcodin import AudioStreamConfig 10 | from bitcodin import VideoStreamConfig 11 | from bitcodin import EncodingProfile 12 | from bitcodin.test.config import test_video_url 13 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 14 | 15 | 16 | class CreateJobTestCase(BitcodinTestCase): 17 | def setUp(self): 18 | super(CreateJobTestCase, self).setUp() 19 | 20 | input_url = test_video_url 21 | input = Input(url=input_url, skip_analysis=True) 22 | 23 | self.input = create_input(input) 24 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 25 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 26 | profile='Main', preset='premium', height=480, width=640) 27 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 28 | self.encoding_profile = create_encoding_profile(encoding_profile) 29 | self.manifests = ['m3u8', 'mpd'] 30 | 31 | def runTest(self): 32 | job = Job( 33 | input_id=self.input.input_id, 34 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 35 | manifest_types=self.manifests, 36 | speed='standard' 37 | ) 38 | self.job = create_job(job) 39 | self.assertEquals(self.job.input.input_id, job.inputId) 40 | self.assertEquals(self.job.input.url, self.input.url) 41 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 42 | self.assertEquals(len(self.job.input.media_configurations), 0) 43 | self.wait_until_job_finished(self.job.job_id) 44 | 45 | def tearDown(self): 46 | delete_input(self.input.input_id) 47 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 48 | super(CreateJobTestCase, self).tearDown() 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_specific_segment_length.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.config import test_video_url 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobWithSpecificSegmentLengthTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobWithSpecificSegmentLengthTestCase, self).setUp() 21 | input_url = test_video_url 22 | input = Input(input_url) 23 | self.input = create_input(input) 24 | audio_stream_config = AudioStreamConfig( 25 | default_stream_id=0, 26 | bitrate=192000 27 | ) 28 | video_stream_config = VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=512000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=640 35 | ) 36 | encoding_profile = EncodingProfile( 37 | name='API Test Profile', 38 | video_stream_configs=[video_stream_config], 39 | audio_stream_configs=[audio_stream_config], 40 | segment_length=2 41 | ) 42 | self.encoding_profile = create_encoding_profile(encoding_profile) 43 | self.manifests = ['m3u8', 'mpd'] 44 | 45 | def runTest(self): 46 | self.assertEqual(self.encoding_profile.segment_length, 2) 47 | job = Job( 48 | input_id=self.input.input_id, 49 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 50 | manifest_types=self.manifests, 51 | speed='standard' 52 | ) 53 | self.job = create_job(job) 54 | self.assertEquals(self.job.input.input_id, job.inputId) 55 | self.assertEquals(self.job.input.url, self.input.url) 56 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 57 | self.wait_until_job_finished(self.job.job_id) 58 | 59 | def tearDown(self): 60 | delete_input(self.input.input_id) 61 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 62 | super(CreateJobWithSpecificSegmentLengthTestCase, self).tearDown() 63 | 64 | 65 | if __name__ == '__main__': 66 | unittest.main() 67 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_specific_video_audio_sample_rates.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.config import test_video_url 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateJobWithSpecificVideoAndAudioSampleRatesTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateJobWithSpecificVideoAndAudioSampleRatesTestCase, self).setUp() 21 | input_url = test_video_url 22 | input = Input(input_url) 23 | self.input = create_input(input) 24 | audio_stream_config = AudioStreamConfig( 25 | default_stream_id=0, 26 | bitrate=192000, 27 | rate=48000 28 | ) 29 | video_stream_config = VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=512000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=640, 36 | rate=24 37 | ) 38 | encoding_profile = EncodingProfile( 39 | name='API Test Profile', 40 | video_stream_configs=[video_stream_config], 41 | audio_stream_configs=[audio_stream_config] 42 | ) 43 | self.encoding_profile = create_encoding_profile(encoding_profile) 44 | self.manifests = ['m3u8', 'mpd'] 45 | 46 | def runTest(self): 47 | job = Job( 48 | input_id=self.input.input_id, 49 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 50 | manifest_types=self.manifests, 51 | speed='standard' 52 | ) 53 | self.job = create_job(job) 54 | self.assertEquals(self.job.input.input_id, job.inputId) 55 | self.assertEquals(self.job.input.url, self.input.url) 56 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 57 | self.wait_until_job_finished(self.job.job_id) 58 | 59 | def tearDown(self): 60 | delete_input(self.input.input_id) 61 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 62 | super(CreateJobWithSpecificVideoAndAudioSampleRatesTestCase, self).tearDown() 63 | 64 | 65 | if __name__ == '__main__': 66 | unittest.main() 67 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_job_widevine_drm_invalid_config.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin import DrmConfig 15 | from bitcodin import WidevineDrmConfig 16 | from bitcodin import PlayreadyDrmConfig 17 | from bitcodin.exceptions import BitcodinBadRequestError 18 | from bitcodin.test.config import test_video_url 19 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 20 | 21 | 22 | class CreateJobWidevineDrmInvalidConfigTestCase(BitcodinTestCase): 23 | def setUp(self): 24 | super(CreateJobWidevineDrmInvalidConfigTestCase, self).setUp() 25 | input_url = test_video_url 26 | input = Input(input_url) 27 | self.input = create_input(input) 28 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 29 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 30 | profile='Main', preset='premium', height=480, width=640) 31 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 32 | self.encoding_profile = create_encoding_profile(encoding_profile) 33 | self.manifests = ['m3u8', 'mpd'] 34 | self.drm_config = WidevineDrmConfig( 35 | provider=None, 36 | signing_key=None, 37 | signing_iv=None, 38 | request_url=None, 39 | content_id=None, 40 | method=None 41 | ) 42 | 43 | def runTest(self): 44 | job = Job( 45 | input_id=self.input.input_id, 46 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 47 | manifest_types=self.manifests, 48 | speed='standard', 49 | drm_config=self.drm_config 50 | ) 51 | with self.assertRaises(BitcodinBadRequestError): 52 | self.job = create_job(job) 53 | 54 | def tearDown(self): 55 | delete_input(self.input.input_id) 56 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 57 | super(CreateJobWidevineDrmInvalidConfigTestCase, self).tearDown() 58 | 59 | 60 | if __name__ == '__main__': 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_create_thumbnail.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job, ThumbnailRequest, create_thumbnail 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import Job 10 | from bitcodin import Input 11 | from bitcodin import AudioStreamConfig 12 | from bitcodin import VideoStreamConfig 13 | from bitcodin import EncodingProfile 14 | from bitcodin.test.config import test_video_url 15 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 16 | 17 | 18 | class CreateThumbnailTestCase(BitcodinTestCase): 19 | def setUp(self): 20 | super(CreateThumbnailTestCase, self).setUp() 21 | input_url = test_video_url 22 | input = Input(input_url) 23 | self.input = create_input(input) 24 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 25 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 26 | profile='Main', preset='premium', height=480, width=640) 27 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 28 | self.encoding_profile = create_encoding_profile(encoding_profile) 29 | self.manifests = ['m3u8', 'mpd'] 30 | 31 | def runTest(self): 32 | job = Job( 33 | input_id=self.input.input_id, 34 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 35 | manifest_types=self.manifests 36 | ) 37 | self.job = create_job(job) 38 | self.assertEquals(self.job.input.input_id, job.inputId) 39 | self.assertEquals(self.job.input.url, self.input.url) 40 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId) 41 | thumbnail_request = ThumbnailRequest(job_id=self.job.job_id, height=320, position=30) 42 | thumbnail = create_thumbnail(thumbnail_request) 43 | self.assertNotEqual(thumbnail.thumbnail_url, None) 44 | 45 | def tearDown(self): 46 | delete_input(self.input.input_id) 47 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 48 | super(CreateThumbnailTestCase, self).tearDown() 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_get_job.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import get_job 10 | from bitcodin import Job 11 | from bitcodin import Input 12 | from bitcodin import AudioStreamConfig 13 | from bitcodin import VideoStreamConfig 14 | from bitcodin import EncodingProfile 15 | from bitcodin.test.config import test_video_url 16 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 17 | 18 | 19 | class GetJobTestCase(BitcodinTestCase): 20 | def setUp(self): 21 | super(GetJobTestCase, self).setUp() 22 | self.maxDiff = None 23 | 24 | input_url = test_video_url 25 | input = Input(input_url) 26 | self.input = create_input(input) 27 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 28 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 29 | profile='Main', preset='premium', height=480, width=640) 30 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 31 | self.encoding_profile = create_encoding_profile(encoding_profile) 32 | self.manifests = ['m3u8', 'mpd'] 33 | job = Job( 34 | input_id=self.input.input_id, 35 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 36 | manifest_types=self.manifests 37 | ) 38 | self.job = create_job(job) 39 | 40 | def runTest(self): 41 | job = get_job(self.job.job_id) 42 | self.assertEquals(self.job.job_id, job.job_id) 43 | self.assertEquals(self.job.created_at.date, self.job.created_at.date) 44 | self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encoding_profiles[0].encoding_profile_id) 45 | self.assertEquals(self.job.manifest_urls.m3u8_url.strip('?')[0], job.manifest_urls.m3u8_url.strip('?')[0]) 46 | self.assertEquals(self.job.manifest_urls.mpd_url.strip('?')[0], job.manifest_urls.mpd_url.strip('?')[0]) 47 | 48 | def tearDown(self): 49 | delete_input(self.input.input_id) 50 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 51 | super(GetJobTestCase, self).tearDown() 52 | 53 | 54 | if __name__ == '__main__': 55 | unittest.main() 56 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_get_job_status.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import get_job_status 10 | from bitcodin import Job 11 | from bitcodin import Input 12 | from bitcodin import AudioStreamConfig 13 | from bitcodin import VideoStreamConfig 14 | from bitcodin import EncodingProfile 15 | from bitcodin.test.config import test_video_url 16 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 17 | 18 | 19 | class GetJobStatusTestCase(BitcodinTestCase): 20 | def setUp(self): 21 | super(GetJobStatusTestCase, self).setUp() 22 | self.maxDiff = None 23 | 24 | input_url = test_video_url 25 | input = Input(input_url) 26 | self.input = create_input(input) 27 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 28 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 29 | profile='Main', preset='premium', height=480, width=640) 30 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 31 | self.encoding_profile = create_encoding_profile(encoding_profile) 32 | self.manifests = ['m3u8', 'mpd'] 33 | job = Job( 34 | input_id=self.input.input_id, 35 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 36 | manifest_types=self.manifests 37 | ) 38 | self.job = create_job(job) 39 | 40 | def runTest(self): 41 | job_status = get_job_status(self.job.job_id) 42 | self.assertEquals(job_status.job_id, self.job.job_id) 43 | self.assertEquals(job_status.status, 'Enqueued') 44 | 45 | def tearDown(self): 46 | delete_input(self.input.input_id) 47 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 48 | super(GetJobStatusTestCase, self).tearDown() 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_get_list_jobs.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_job 5 | from bitcodin import create_input 6 | from bitcodin import create_encoding_profile 7 | from bitcodin import delete_input 8 | from bitcodin import delete_encoding_profile 9 | from bitcodin import list_jobs 10 | from bitcodin import Job 11 | from bitcodin import Input 12 | from bitcodin import AudioStreamConfig 13 | from bitcodin import VideoStreamConfig 14 | from bitcodin import EncodingProfile 15 | from bitcodin.test.config import test_video_url 16 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 17 | 18 | 19 | class GetJobListTestCase(BitcodinTestCase): 20 | def setUp(self): 21 | super(GetJobListTestCase, self).setUp() 22 | input_url = test_video_url 23 | input = Input(input_url) 24 | self.input = create_input(input) 25 | audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000) 26 | video_stream_config = VideoStreamConfig(default_stream_id=0, bitrate=512000, 27 | profile='Main', preset='premium', height=480, width=640) 28 | encoding_profile = EncodingProfile('API Test Profile', [video_stream_config], [audio_stream_config]) 29 | self.encoding_profile = create_encoding_profile(encoding_profile) 30 | self.manifests = ['m3u8', 'mpd'] 31 | job = Job( 32 | input_id=self.input.input_id, 33 | encoding_profile_id=self.encoding_profile.encoding_profile_id, 34 | manifest_types=self.manifests 35 | ) 36 | self.job = create_job(job) 37 | 38 | def runTest(self): 39 | jobs = list_jobs() 40 | job_found = False 41 | for job in jobs: 42 | if job.job_id == self.job.job_id: 43 | job_found = True 44 | break 45 | 46 | self.assertEquals(job_found, True) 47 | 48 | def tearDown(self): 49 | delete_input(self.input.input_id) 50 | delete_encoding_profile(self.encoding_profile.encoding_profile_id) 51 | super(GetJobListTestCase, self).tearDown() 52 | 53 | 54 | if __name__ == '__main__': 55 | unittest.main() 56 | -------------------------------------------------------------------------------- /bitcodin/test/job/testcase_get_non_existent_job.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import get_job 5 | from bitcodin.exceptions import BitcodinNotFoundError 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class GetNonExistentJobTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(GetNonExistentJobTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | with self.assertRaises(BitcodinNotFoundError): 15 | get_job(0) 16 | 17 | def tearDown(self): 18 | super(GetNonExistentJobTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/test/live_stream/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'David Moser ' 2 | 3 | from unittest import TestSuite 4 | 5 | from .testcase_create_delete_live_stream import CreateLiveStreamTestCase 6 | 7 | 8 | def get_test_suite(): 9 | test_suite = TestSuite() 10 | test_suite.addTest(CreateLiveStreamTestCase()) 11 | 12 | return test_suite 13 | -------------------------------------------------------------------------------- /bitcodin/test/notifications/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Jan Češpivo ' 2 | 3 | from unittest import TestSuite 4 | 5 | from .testcase_get_list_events import ListEventsTestCase 6 | from .testcase_get_list_subscriptions import GetSubscriptionListTestCase 7 | from .testcase_get_subscription import GetSubscriptionTestCase 8 | from .testcase_delete_subscription import DeleteSubscriptionTestCase 9 | 10 | 11 | def get_test_suite(): 12 | test_suite = TestSuite() 13 | test_suite.addTest(ListEventsTestCase()) 14 | test_suite.addTest(GetSubscriptionListTestCase()) 15 | test_suite.addTest(GetSubscriptionTestCase()) 16 | test_suite.addTest(DeleteSubscriptionTestCase()) 17 | return test_suite 18 | -------------------------------------------------------------------------------- /bitcodin/test/notifications/testcase_delete_subscription.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Jan Češpivo ' 2 | 3 | import unittest 4 | 5 | from bitcodin import Subscription 6 | from bitcodin import list_events 7 | from bitcodin import create_subscription 8 | from bitcodin import delete_subscription 9 | 10 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 11 | 12 | 13 | class DeleteSubscriptionTestCase(BitcodinTestCase): 14 | def setUp(self): 15 | super(DeleteSubscriptionTestCase, self).setUp() 16 | event = next((event for event in list_events() if event.name == 'encoding.finished')) 17 | subscription = Subscription(event_id=event.id, url='http://www.example.com/') 18 | self.created_subscription = create_subscription(subscription) 19 | 20 | def runTest(self): 21 | delete_subscription(self.created_subscription.id) 22 | 23 | def tearDown(self): 24 | super(DeleteSubscriptionTestCase, self).tearDown() 25 | 26 | 27 | if __name__ == '__main__': 28 | unittest.main() 29 | -------------------------------------------------------------------------------- /bitcodin/test/notifications/testcase_get_list_events.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Jan Češpivo ' 2 | 3 | import unittest 4 | from bitcodin import list_events 5 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 6 | 7 | 8 | class ListEventsTestCase(BitcodinTestCase): 9 | def runTest(self): 10 | events = list_events() 11 | for event in events: 12 | self.assertEquals(hasattr(event, 'id'), True) 13 | self.assertEquals(hasattr(event, 'name'), True) 14 | self.assertEquals(hasattr(event, 'description'), True) 15 | 16 | if __name__ == '__main__': 17 | unittest.main() 18 | -------------------------------------------------------------------------------- /bitcodin/test/notifications/testcase_get_list_subscriptions.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Jan Češpivo ' 2 | 3 | import unittest 4 | 5 | from bitcodin import Subscription 6 | from bitcodin import list_events 7 | from bitcodin import create_subscription 8 | from bitcodin import list_subscriptions 9 | from bitcodin import delete_subscription 10 | 11 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 12 | 13 | 14 | class GetSubscriptionListTestCase(BitcodinTestCase): 15 | def setUp(self): 16 | super(GetSubscriptionListTestCase, self).setUp() 17 | event = next((event for event in list_events() if event.name == 'encoding.finished')) 18 | subscription = Subscription(event_id=event.id, url='http://www.example.com/') 19 | self.created_subscription = create_subscription(subscription) 20 | 21 | def runTest(self): 22 | subscriptions = list_subscriptions() 23 | subscription_found = False 24 | for subscription in subscriptions: 25 | if self.created_subscription.id == subscription.id: 26 | subscription_found = True 27 | break 28 | self.assertEquals(subscription_found, True) 29 | 30 | def tearDown(self): 31 | delete_subscription(self.created_subscription.id) 32 | super(GetSubscriptionListTestCase, self).tearDown() 33 | 34 | 35 | if __name__ == '__main__': 36 | unittest.main() 37 | -------------------------------------------------------------------------------- /bitcodin/test/notifications/testcase_get_subscription.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Jan Češpivo ' 2 | 3 | import unittest 4 | 5 | from bitcodin import Subscription 6 | from bitcodin import list_events 7 | from bitcodin import get_subscription 8 | from bitcodin import create_subscription 9 | from bitcodin import delete_subscription 10 | 11 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 12 | 13 | 14 | class GetSubscriptionTestCase(BitcodinTestCase): 15 | def setUp(self): 16 | super(GetSubscriptionTestCase, self).setUp() 17 | event = next((event for event in list_events() if event.name == 'encoding.finished')) 18 | subscription = Subscription(event_id=event.id, url='http://www.example.com/') 19 | self.created_subscription = create_subscription(subscription) 20 | 21 | def runTest(self): 22 | subscription_id = self.created_subscription.id 23 | subscription = get_subscription(subscription_id) 24 | self.assertEquals(self.created_subscription, subscription) 25 | 26 | def tearDown(self): 27 | delete_subscription(self.created_subscription.id) 28 | super(GetSubscriptionTestCase, self).tearDown() 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /bitcodin/test/output/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | from unittest import TestSuite 4 | 5 | from .testcase_create_s3_output_incomplete import CreateS3OutputIncompleteDataTestCase 6 | from .testcase_create_s3_output_invalid import CreateS3OutputInvalidDataTestCase 7 | from .testcase_create_s3_output import CreateS3OutputTestCase 8 | from .testcase_get_s3_output import GetS3OutputTestCase 9 | from .testcase_create_ftp_output_incomplete import CreateFTPOutputIncompleteDataTestCase 10 | from .testcase_create_ftp_output_invalid import CreateFTPOutputInvalidDataTestCase 11 | from .testcase_create_ftp_output import CreateFTPOutputTestCase 12 | from .testcase_get_ftp_output import GetFTPOutputTestCase 13 | from .testcase_get_non_existent_output import GetNonExistentOutputTestCase 14 | from .testcase_delete_s3_output import DeleteS3OutputTestCase 15 | from .testcase_delete_ftp_output import DeleteFTPOutputTestCase 16 | from .testcase_create_gcs_output import CreateGCSOutputTestCase 17 | from .testcase_delete_gcs_output import DeleteGCSOutputTestCase 18 | from .testcase_get_gcs_output import GetGCSOutputTestCase 19 | from .testcase_create_azure_output import CreateAzureOutputTestCase 20 | 21 | 22 | def get_test_suite(): 23 | test_suite = TestSuite() 24 | test_suite.addTest(CreateS3OutputIncompleteDataTestCase()) 25 | test_suite.addTest(CreateS3OutputInvalidDataTestCase()) 26 | test_suite.addTest(CreateS3OutputTestCase()) 27 | test_suite.addTest(GetS3OutputTestCase()) 28 | test_suite.addTest(CreateFTPOutputIncompleteDataTestCase()) 29 | test_suite.addTest(CreateFTPOutputInvalidDataTestCase()) 30 | test_suite.addTest(CreateFTPOutputTestCase()) 31 | test_suite.addTest(GetFTPOutputTestCase()) 32 | test_suite.addTest(GetNonExistentOutputTestCase()) 33 | test_suite.addTest(DeleteS3OutputTestCase()) 34 | test_suite.addTest(DeleteFTPOutputTestCase()) 35 | test_suite.addTest(CreateGCSOutputTestCase()) 36 | test_suite.addTest(DeleteGCSOutputTestCase()) 37 | test_suite.addTest(GetGCSOutputTestCase()) 38 | test_suite.addTest(CreateAzureOutputTestCase()) 39 | 40 | return test_suite 41 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_create_azure_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import delete_output 6 | from bitcodin import AzureOutput 7 | from bitcodin.test.settings import azure_output_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateAzureOutputTestCase(BitcodinTestCase): 12 | 13 | output = None 14 | 15 | def setUp(self): 16 | super(CreateAzureOutputTestCase, self).setUp() 17 | 18 | def runTest(self): 19 | output = AzureOutput( 20 | name='Azure Test Output Python', 21 | account_name=azure_output_config.get('accountName'), 22 | account_key=azure_output_config.get('accountKey'), 23 | container=azure_output_config.get('container'), 24 | prefix=azure_output_config.get('prefix') 25 | ) 26 | 27 | self.output = create_output(output) 28 | self.assertEquals(self.output.name, output.name) 29 | self.assertEquals(self.output.container, output.container) 30 | 31 | def tearDown(self): 32 | delete_output(self.output.output_id) 33 | super(CreateAzureOutputTestCase, self).tearDown() 34 | 35 | 36 | if __name__ == '__main__': 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_create_ftp_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import delete_output 6 | from bitcodin import FTPOutput 7 | from bitcodin.test.settings import ftp_output_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateFTPOutputTestCase(BitcodinTestCase): 12 | 13 | output = None 14 | 15 | def setUp(self): 16 | super(CreateFTPOutputTestCase, self).setUp() 17 | self.ftp_configuration = { 18 | 'name': 'Python API Test FTP Output', 19 | 'host': ftp_output_config.get('host', None), 20 | 'username': ftp_output_config.get('username', None), 21 | 'password': ftp_output_config.get('password', None), 22 | 'passive': True 23 | } 24 | 25 | def runTest(self): 26 | output = FTPOutput( 27 | name=self.ftp_configuration.get('name'), 28 | host=self.ftp_configuration.get('host'), 29 | basic_auth_user=self.ftp_configuration.get('username'), 30 | basic_auth_password=self.ftp_configuration.get('password'), 31 | passive=self.ftp_configuration.get('passive') 32 | ) 33 | 34 | self.output = create_output(output) 35 | self.assertEquals(self.output.name, output.name) 36 | self.assertEquals(self.output.host, output.host.split('/')[0]) 37 | self.assertEquals(self.output.passive, output.passive) 38 | 39 | def tearDown(self): 40 | delete_output(self.output.output_id) 41 | super(CreateFTPOutputTestCase, self).tearDown() 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_create_ftp_output_incomplete.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import FTPOutput 6 | from bitcodin.test.settings import ftp_output_config 7 | from bitcodin.exceptions import BitcodinBadRequestError 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateFTPOutputIncompleteDataTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(CreateFTPOutputIncompleteDataTestCase, self).setUp() 14 | self.ftp_configuration = { 15 | 'name': 'Python API Test FTP Output', 16 | 'host': ftp_output_config.get('host', None), 17 | 'username': ftp_output_config.get('username', None), 18 | 'password': ftp_output_config.get('password', None), 19 | 'passive': True 20 | } 21 | 22 | def runTest(self): 23 | output = FTPOutput( 24 | name=self.ftp_configuration.get('name'), 25 | host='', 26 | basic_auth_user=self.ftp_configuration.get('username'), 27 | basic_auth_password=self.ftp_configuration.get('password'), 28 | passive=self.ftp_configuration.get('passive') 29 | ) 30 | 31 | with self.assertRaises(BitcodinBadRequestError): 32 | result = create_output(output) 33 | 34 | def tearDown(self): 35 | super(CreateFTPOutputIncompleteDataTestCase, self).tearDown() 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_create_ftp_output_invalid.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import FTPOutput 6 | from bitcodin.test.settings import ftp_output_config 7 | from bitcodin.exceptions import BitcodinBadRequestError 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateFTPOutputInvalidDataTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(CreateFTPOutputInvalidDataTestCase, self).setUp() 14 | self.ftp_configuration = { 15 | 'name': 'Python API Test FTP Output', 16 | 'host': ftp_output_config.get('host', None), 17 | 'username': ftp_output_config.get('username', None), 18 | 'password': ftp_output_config.get('password', None), 19 | 'passive': True 20 | } 21 | 22 | def runTest(self): 23 | output = FTPOutput( 24 | name=self.ftp_configuration.get('name'), 25 | host='i.am.a.invalid.host.bitmovin.net/myinvalidfolder', 26 | basic_auth_user=self.ftp_configuration.get('username'), 27 | basic_auth_password=self.ftp_configuration.get('password'), 28 | passive=self.ftp_configuration.get('passive') 29 | ) 30 | 31 | with self.assertRaises(BitcodinBadRequestError): 32 | result = create_output(output) 33 | 34 | def tearDown(self): 35 | super(CreateFTPOutputInvalidDataTestCase, self).tearDown() 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_create_gcs_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import delete_output 6 | from bitcodin import GCSOutput 7 | from bitcodin.test.settings import gcs_output_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateGCSOutputTestCase(BitcodinTestCase): 12 | output = None 13 | 14 | def setUp(self): 15 | super(CreateGCSOutputTestCase, self).setUp() 16 | 17 | def runTest(self): 18 | output = GCSOutput( 19 | name='Python Test Output', 20 | access_key=gcs_output_config.get('accessKey'), 21 | secret_key=gcs_output_config.get('secretKey'), 22 | bucket=gcs_output_config.get('bucket'), 23 | prefix=gcs_output_config.get('prefix'), 24 | make_public=False 25 | ) 26 | 27 | self.output = create_output(output) 28 | self.assertEquals(self.output.name, output.name) 29 | self.assertEquals(self.output.bucket, output.bucket) 30 | 31 | def tearDown(self): 32 | delete_output(self.output.output_id) 33 | super(CreateGCSOutputTestCase, self).tearDown() 34 | 35 | 36 | if __name__ == '__main__': 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_create_s3_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import delete_output 6 | from bitcodin import S3Output 7 | from bitcodin.test.settings import s3_output_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateS3OutputTestCase(BitcodinTestCase): 12 | 13 | output = None 14 | 15 | def setUp(self): 16 | super(CreateS3OutputTestCase, self).setUp() 17 | self.s3_configuration = { 18 | 'name': 'Python API Test Output', 19 | 'host': s3_output_config.get('host', None), 20 | 'access_key': s3_output_config.get('access_key', None), 21 | 'secret_key': s3_output_config.get('secret_key', None), 22 | 'bucket': s3_output_config.get('bucket', None), 23 | 'prefix': s3_output_config.get('prefix', None), 24 | 'region': s3_output_config.get('region', None), 25 | 'make_public': False 26 | } 27 | self.output = S3Output( 28 | name=self.s3_configuration.get('name'), 29 | host=self.s3_configuration.get('host'), 30 | access_key=self.s3_configuration.get('access_key'), 31 | secret_key=self.s3_configuration.get('secret_key'), 32 | bucket=self.s3_configuration.get('bucket'), 33 | prefix=self.s3_configuration.get('prefix'), 34 | region=self.s3_configuration.get('region'), 35 | make_public=self.s3_configuration.get('make_public') 36 | ) 37 | 38 | def runTest(self): 39 | output = S3Output( 40 | name=self.s3_configuration.get('name'), 41 | host=self.s3_configuration.get('host'), 42 | access_key=self.s3_configuration.get('access_key'), 43 | secret_key=self.s3_configuration.get('secret_key'), 44 | bucket=self.s3_configuration.get('bucket'), 45 | prefix=self.s3_configuration.get('prefix'), 46 | region=self.s3_configuration.get('region'), 47 | make_public=self.s3_configuration.get('make_public') 48 | ) 49 | self.output = create_output(output) 50 | self.assertEquals(self.output.name, self.s3_configuration['name']) 51 | self.assertEquals(self.output.bucket, self.s3_configuration.get('bucket')) 52 | self.assertEquals(self.output.prefix, self.s3_configuration.get('prefix')) 53 | self.assertEquals(self.output.region, self.s3_configuration.get('region')) 54 | self.assertEquals(self.output.make_public, self.s3_configuration.get('make_public')) 55 | 56 | def tearDown(self): 57 | delete_output(self.output.output_id) 58 | super(CreateS3OutputTestCase, self).tearDown() 59 | 60 | 61 | if __name__ == '__main__': 62 | unittest.main() 63 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_create_s3_output_incomplete.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import S3Output 6 | from bitcodin.test.settings import s3_output_config 7 | from bitcodin.exceptions import BitcodinBadRequestError 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateS3OutputIncompleteDataTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(CreateS3OutputIncompleteDataTestCase, self).setUp() 14 | self.s3_configuration = { 15 | 'name': 'Python API Test Output', 16 | 'host': s3_output_config.get('host', None), 17 | 'access_key': s3_output_config.get('access_key', None), 18 | 'secret_key': s3_output_config.get('secret_key', None), 19 | 'bucket': s3_output_config.get('bucket', None), 20 | 'prefix': s3_output_config.get('prefix', None), 21 | 'region': s3_output_config.get('region', None), 22 | 'make_public': False 23 | } 24 | 25 | def runTest(self): 26 | output = S3Output( 27 | name=self.s3_configuration.get('name'), 28 | host=self.s3_configuration.get('host'), 29 | access_key=self.s3_configuration.get('access_key'), 30 | secret_key=self.s3_configuration.get('secret_key'), 31 | bucket='', 32 | prefix=self.s3_configuration.get('prefix'), 33 | region=self.s3_configuration.get('region'), 34 | make_public=self.s3_configuration.get('make_public') 35 | ) 36 | 37 | with self.assertRaises(BitcodinBadRequestError): 38 | result = create_output(output) 39 | 40 | def tearDown(self): 41 | super(CreateS3OutputIncompleteDataTestCase, self).tearDown() 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_create_s3_output_invalid.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import S3Output 6 | from bitcodin.test.settings import s3_output_config 7 | from bitcodin.exceptions import BitcodinBadRequestError 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class CreateS3OutputInvalidDataTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(CreateS3OutputInvalidDataTestCase, self).setUp() 14 | self.s3_configuration = { 15 | 'name': 'Python API Test Output', 16 | 'host': s3_output_config.get('host', None), 17 | 'access_key': s3_output_config.get('access_key', None), 18 | 'secret_key': s3_output_config.get('secret_key', None), 19 | 'bucket': s3_output_config.get('bucket', None), 20 | 'prefix': s3_output_config.get('prefix', None), 21 | 'region': s3_output_config.get('region', None), 22 | 'make_public': False 23 | } 24 | 25 | def runTest(self): 26 | output = S3Output( 27 | name=self.s3_configuration.get('name'), 28 | host=self.s3_configuration.get('host'), 29 | access_key=self.s3_configuration.get('access_key'), 30 | secret_key=self.s3_configuration.get('secret_key'), 31 | bucket=self.s3_configuration.get('bucket'), 32 | prefix=self.s3_configuration.get('prefix'), 33 | region='eu-south-22', 34 | make_public=self.s3_configuration.get('make_public') 35 | ) 36 | 37 | with self.assertRaises(BitcodinBadRequestError): 38 | result = create_output(output) 39 | 40 | def tearDown(self): 41 | super(CreateS3OutputInvalidDataTestCase, self).tearDown() 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_delete_ftp_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import FTPOutput 5 | from bitcodin import create_output 6 | from bitcodin import delete_output 7 | from bitcodin import get_output 8 | from bitcodin.exceptions import BitcodinNotFoundError 9 | from bitcodin.test.settings import ftp_output_config 10 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 11 | 12 | 13 | class DeleteFTPOutputTestCase(BitcodinTestCase): 14 | def setUp(self): 15 | super(DeleteFTPOutputTestCase, self).setUp() 16 | self.ftp_configuration = { 17 | 'name': 'Python API Test FTP Output', 18 | 'host': ftp_output_config.get('host', None), 19 | 'username': ftp_output_config.get('username', None), 20 | 'password': ftp_output_config.get('password', None), 21 | 'passive': True 22 | } 23 | 24 | def runTest(self): 25 | output = FTPOutput( 26 | name=self.ftp_configuration.get('name'), 27 | host=self.ftp_configuration.get('host'), 28 | basic_auth_user=self.ftp_configuration.get('username'), 29 | basic_auth_password=self.ftp_configuration.get('password'), 30 | passive=self.ftp_configuration.get('passive') 31 | ) 32 | self.output = create_output(output) 33 | self.assertIsNotNone(self.output.output_id) 34 | 35 | delete_output(self.output.output_id) 36 | with self.assertRaises(BitcodinNotFoundError): 37 | get_output(self.output.output_id) 38 | 39 | def tearDown(self): 40 | super(DeleteFTPOutputTestCase, self).tearDown() 41 | 42 | 43 | if __name__ == '__main__': 44 | unittest.main() 45 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_delete_gcs_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import GCSOutput 5 | from bitcodin import create_output 6 | from bitcodin import delete_output 7 | from bitcodin.test.settings import gcs_output_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class DeleteGCSOutputTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(DeleteGCSOutputTestCase, self).setUp() 14 | output = GCSOutput( 15 | name='Python Test Output', 16 | access_key=gcs_output_config.get('accessKey'), 17 | secret_key=gcs_output_config.get('secretKey'), 18 | bucket=gcs_output_config.get('bucket'), 19 | prefix=gcs_output_config.get('prefix'), 20 | make_public=False 21 | ) 22 | self.output = create_output(output) 23 | 24 | def runTest(self): 25 | delete_output(self.output.output_id) 26 | 27 | def tearDown(self): 28 | super(DeleteGCSOutputTestCase, self).tearDown() 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_delete_s3_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import S3Output 5 | from bitcodin import create_output 6 | from bitcodin import delete_output 7 | from bitcodin.test.settings import s3_output_config 8 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 9 | 10 | 11 | class DeleteS3OutputTestCase(BitcodinTestCase): 12 | def setUp(self): 13 | super(DeleteS3OutputTestCase, self).setUp() 14 | self.s3_configuration = { 15 | 'name': 'Python API Test Output', 16 | 'host': s3_output_config.get('host', None), 17 | 'access_key': s3_output_config.get('access_key', None), 18 | 'secret_key': s3_output_config.get('secret_key', None), 19 | 'bucket': s3_output_config.get('bucket', None), 20 | 'prefix': s3_output_config.get('prefix', None), 21 | 'region': s3_output_config.get('region', None), 22 | 'make_public': False 23 | } 24 | output = S3Output( 25 | name=self.s3_configuration.get('name'), 26 | host=self.s3_configuration.get('host'), 27 | access_key=self.s3_configuration.get('access_key'), 28 | secret_key=self.s3_configuration.get('secret_key'), 29 | bucket=self.s3_configuration.get('bucket'), 30 | prefix=self.s3_configuration.get('prefix'), 31 | region=self.s3_configuration.get('region'), 32 | make_public=self.s3_configuration.get('make_public') 33 | ) 34 | self.output = create_output(output) 35 | 36 | def runTest(self): 37 | delete_output(self.output.output_id) 38 | 39 | def tearDown(self): 40 | super(DeleteS3OutputTestCase, self).tearDown() 41 | 42 | 43 | if __name__ == '__main__': 44 | unittest.main() 45 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_get_ftp_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import delete_output 6 | from bitcodin import get_output 7 | from bitcodin import FTPOutput 8 | from bitcodin.test.settings import ftp_output_config 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class GetFTPOutputTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(GetFTPOutputTestCase, self).setUp() 15 | self.ftp_configuration = { 16 | 'name': 'Python API Test FTP Output', 17 | 'host': ftp_output_config.get('host', None), 18 | 'username': ftp_output_config.get('username', None), 19 | 'password': ftp_output_config.get('password', None), 20 | 'passive': True 21 | } 22 | output = FTPOutput( 23 | name=self.ftp_configuration.get('name'), 24 | host=self.ftp_configuration.get('host'), 25 | basic_auth_user=self.ftp_configuration.get('username'), 26 | basic_auth_password=self.ftp_configuration.get('password'), 27 | passive=self.ftp_configuration.get('passive') 28 | ) 29 | self.output = create_output(output) 30 | 31 | def runTest(self): 32 | output = get_output(self.output.output_id) 33 | self.assertEquals(self.output.name, output.name) 34 | self.assertEquals(self.output.host, output.host.split('/')[0]) 35 | self.assertEquals(self.output.passive, output.passive) 36 | 37 | def tearDown(self): 38 | delete_output(self.output.output_id) 39 | super(GetFTPOutputTestCase, self).tearDown() 40 | 41 | 42 | if __name__ == '__main__': 43 | unittest.main() 44 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_get_gcs_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import delete_output 6 | from bitcodin import get_output 7 | from bitcodin import GCSOutput 8 | from bitcodin.test.settings import gcs_output_config 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class GetGCSOutputTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(GetGCSOutputTestCase, self).setUp() 15 | output = GCSOutput( 16 | name='Python Test Output', 17 | access_key=gcs_output_config.get('accessKey'), 18 | secret_key=gcs_output_config.get('secretKey'), 19 | bucket=gcs_output_config.get('bucket'), 20 | prefix=gcs_output_config.get('prefix'), 21 | make_public=False 22 | ) 23 | self.output = create_output(output) 24 | self.output = get_output(self.output.output_id) 25 | 26 | def runTest(self): 27 | output = get_output(self.output.output_id) 28 | self.assertEquals(self.output.name, output.name) 29 | self.assertEquals(self.output.bucket, output.bucket) 30 | self.assertEquals(self.output.prefix, output.prefix) 31 | 32 | def tearDown(self): 33 | delete_output(self.output.output_id) 34 | super(GetGCSOutputTestCase, self).tearDown() 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_get_non_existent_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import get_output 5 | from bitcodin.exceptions import BitcodinNotFoundError 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | 8 | 9 | class GetNonExistentOutputTestCase(BitcodinTestCase): 10 | def setUp(self): 11 | super(GetNonExistentOutputTestCase, self).setUp() 12 | 13 | def runTest(self): 14 | with self.assertRaises(BitcodinNotFoundError): 15 | encoding_profile = get_output(0) 16 | 17 | def tearDown(self): 18 | super(GetNonExistentOutputTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/test/output/testcase_get_s3_output.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | from bitcodin import create_output 5 | from bitcodin import delete_output 6 | from bitcodin import get_output 7 | from bitcodin import S3Output 8 | from bitcodin.test.settings import s3_output_config 9 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 10 | 11 | 12 | class GetS3OutputTestCase(BitcodinTestCase): 13 | def setUp(self): 14 | super(GetS3OutputTestCase, self).setUp() 15 | self.s3_configuration = { 16 | 'name': 'Python API Test Output', 17 | 'host': s3_output_config.get('host', None), 18 | 'access_key': s3_output_config.get('access_key', None), 19 | 'secret_key': s3_output_config.get('secret_key', None), 20 | 'bucket': s3_output_config.get('bucket', None), 21 | 'prefix': s3_output_config.get('prefix', None), 22 | 'region': s3_output_config.get('region', None), 23 | 'make_public': False 24 | } 25 | output = S3Output( 26 | access_key=self.s3_configuration.get('access_key'), 27 | secret_key=self.s3_configuration.get('secret_key'), 28 | name=self.s3_configuration.get('name'), 29 | host=self.s3_configuration.get('host'), 30 | bucket=self.s3_configuration.get('bucket'), 31 | prefix=self.s3_configuration.get('prefix'), 32 | region=self.s3_configuration.get('region'), 33 | make_public=self.s3_configuration.get('make_public') 34 | ) 35 | self.output = create_output(output) 36 | 37 | def runTest(self): 38 | output = get_output(self.output.output_id) 39 | 40 | self.assertEquals(self.output.name, output.name) 41 | self.assertEquals(self.output.bucket, output.bucket) 42 | self.assertEquals(self.output.prefix, output.prefix) 43 | self.assertEquals(self.output.region, output.region) 44 | self.assertEquals(self.output.make_public, output.make_public) 45 | 46 | def tearDown(self): 47 | delete_output(self.output.output_id) 48 | super(GetS3OutputTestCase, self).tearDown() 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /bitcodin/test/settings.py.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmovin/bitcodin-python/117e755f6aac657f9bb0e95862d2e9a5e4f2abff/bitcodin/test/settings.py.enc -------------------------------------------------------------------------------- /bitcodin/test/statistics/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | from unittest import TestSuite 4 | from .testcase_get_statistics_current import GetStatisticsCurrentMonthTestCase 5 | from .testcase_get_statistics_from_to import GetStatisticsFromToTestCase 6 | 7 | 8 | def get_test_suite(): 9 | test_suite = TestSuite() 10 | #test_suite.addTest(GetStatisticsCurrentMonthTestCase()) 11 | #test_suite.addTest(GetStatisticsFromToTestCase()) 12 | 13 | return test_suite 14 | -------------------------------------------------------------------------------- /bitcodin/test/statistics/testcase_get_statistics_current.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | 5 | import bitcodin 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | from bitcodin.rest import RestClient 8 | 9 | 10 | class GetStatisticsCurrentMonthTestCase(BitcodinTestCase): 11 | def setUp(self): 12 | super(GetStatisticsCurrentMonthTestCase, self).setUp() 13 | 14 | def runTest(self): 15 | response = RestClient.get(url=bitcodin.get_api_base()+'/statistics', headers=bitcodin.create_headers()) 16 | 17 | def tearDown(self): 18 | super(GetStatisticsCurrentMonthTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/test/statistics/testcase_get_statistics_from_to.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dominic Miglar ' 2 | 3 | import unittest 4 | 5 | import bitcodin 6 | from bitcodin.test.bitcodin_test_case import BitcodinTestCase 7 | from bitcodin.rest import RestClient 8 | 9 | 10 | class GetStatisticsFromToTestCase(BitcodinTestCase): 11 | def setUp(self): 12 | super(GetStatisticsFromToTestCase, self).setUp() 13 | 14 | def runTest(self): 15 | response = RestClient.get(url=bitcodin.get_api_base()+'/statistics/2000-12-24/2100-12-24', headers=bitcodin.create_headers()) 16 | 17 | def tearDown(self): 18 | super(GetStatisticsFromToTestCase, self).tearDown() 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /bitcodin/util.py: -------------------------------------------------------------------------------- 1 | import re 2 | from six import string_types 3 | 4 | __author__ = 'David Moser ' 5 | 6 | 7 | def convert_dict(d): 8 | """ 9 | Converts all camelCase styles attributes in the dictionary d to snake_case attributes. 10 | Returns the new dictionary which contains the snake_case attributes. 11 | :param d 12 | """ 13 | if d is None: 14 | return 15 | 16 | new_d = {} 17 | for k, v in d.items(): 18 | if isinstance(v, string_types): 19 | if isint(v): 20 | v = int(v) 21 | elif isfloat(v): 22 | v = float(v) 23 | else: 24 | v = v 25 | 26 | if isinstance(v, list): 27 | index = 0 28 | for d in v: 29 | if isinstance(d, dict): 30 | v[index] = convert_dict(d) 31 | index += 1 32 | del index 33 | 34 | new_d[convert(k)] = convert_dict(v) if isinstance(v, dict) else v 35 | 36 | return new_d 37 | 38 | 39 | def convert(name): 40 | """ 41 | Converts camelCase strings to snake_case ones. 42 | :param name 43 | """ 44 | s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) 45 | return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() 46 | 47 | 48 | def isfloat(x): 49 | try: 50 | a = float(x) 51 | except ValueError: 52 | return False 53 | else: 54 | return True 55 | 56 | 57 | def isint(x): 58 | try: 59 | a = float(x) 60 | b = int(a) 61 | except ValueError: 62 | return False 63 | else: 64 | return a == b 65 | -------------------------------------------------------------------------------- /examples/create_job.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | print("INPUT REQUEST: %s\n\n" % input_obj.to_json()) 10 | input_result = bitcodin.create_input(input_obj) 11 | print("INPUT RESULT: %s\n\n" % input_result.to_json()) 12 | 13 | video_configs = list() 14 | 15 | video_configs.append(bitcodin.VideoStreamConfig( 16 | default_stream_id=0, 17 | bitrate=4800000, 18 | profile='Main', 19 | preset='premium', 20 | height=1080, 21 | width=1920 22 | )) 23 | video_configs.append(bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=2400000, 26 | profile='Main', 27 | preset='premium', 28 | height=768, 29 | width=1024 30 | )) 31 | video_configs.append(bitcodin.VideoStreamConfig( 32 | default_stream_id=0, 33 | bitrate=1200000, 34 | profile='Main', 35 | preset='premium', 36 | height=480, 37 | width=854 38 | )) 39 | 40 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 41 | 42 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 43 | print("ENCODING PROFILE REQUEST %s\n\n" % encoding_profile_obj.to_json()) 44 | 45 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 46 | print("ENCODING PROFILE RESULT %s\n\n" % encoding_profile_result.to_json()) 47 | 48 | manifests = ['mpd', 'm3u8'] 49 | 50 | job = bitcodin.Job( 51 | input_id=input_result.input_id, 52 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 53 | manifest_types=manifests, 54 | speed='standard' 55 | ) 56 | print("JOB: %s" % job.to_json()) 57 | 58 | job_result = bitcodin.create_job(job) 59 | while job_result.status != 'Finished' and job_result.status != 'Error': 60 | job_result = bitcodin.get_job(job_result.job_id) 61 | print(job_result.to_json()) 62 | sleep(5) 63 | 64 | print(job_result.to_json()) 65 | print("Job Finished!") 66 | 67 | -------------------------------------------------------------------------------- /examples/create_job_autotransfer_azure.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 39 | 40 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 41 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 42 | 43 | manifests = ['mpd', 'm3u8'] 44 | 45 | output_obj = bitcodin.AzureOutput( 46 | name='Azure Test Output Python', 47 | account_name='yourAzureAccountName', 48 | account_key='yourAzureAccountKey', 49 | container='yourAzureContainer', 50 | prefix='yourDesiredPrefixInsideTheContainer' 51 | ) 52 | 53 | output_result = bitcodin.create_output(output_obj) 54 | 55 | # Simply give a output_id to the job configuration to which the results should be copied when the job is finished. 56 | job = bitcodin.Job( 57 | input_id=input_result.input_id, 58 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 59 | manifest_types=manifests, 60 | output_id=output_result.output_id 61 | ) 62 | job_result = bitcodin.create_job(job) 63 | 64 | while job_result.status != 'Finished' and job_result.status != 'Error': 65 | job_result = bitcodin.get_job(job_result.job_id) 66 | print(job_result.to_json()) 67 | sleep(5) 68 | 69 | print(job_result.to_json()) 70 | print("Job Finished!") 71 | -------------------------------------------------------------------------------- /examples/create_job_autotransfer_s3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 39 | 40 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 41 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 42 | 43 | manifests = ['mpd', 'm3u8'] 44 | 45 | output_obj = bitcodin.S3Output( 46 | name='MY S3 Output Profile', 47 | host='YOUR AWS HOST', 48 | access_key='YOUR AWS ACCESS KEY', 49 | secret_key='YOUR AWS SECRET KEY', 50 | bucket='YOUR AWS BUCKET NAME', 51 | prefix='PATH/TO/MY/DESIRED/OUTPUT/DESTINATION/', 52 | region='YOUR AWS REGION', 53 | make_public=False 54 | ) 55 | output_result = bitcodin.create_output(output_obj) 56 | 57 | 58 | # Simply give a output_id to the job configuration to which the results should be copied when the job is finished. 59 | job = bitcodin.Job( 60 | input_id=input_result.input_id, 61 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 62 | manifest_types=manifests, 63 | output_id=output_result.output_id 64 | ) 65 | job_result = bitcodin.create_job(job) 66 | 67 | while job_result.status != 'Finished' and job_result.status != 'Error': 68 | job_result = bitcodin.get_job(job_result.job_id) 69 | print(job_result.to_json()) 70 | sleep(5) 71 | 72 | print(job_result.to_json()) 73 | print("Job Finished!") 74 | -------------------------------------------------------------------------------- /examples/create_job_azure_input.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.AzureInput( 9 | account_name="AZURE BLOB ACCOUNT NAME", 10 | account_key="AZURE BLOB ACCOUNT KEY", 11 | container="AZURE BLOB CONTAINER", 12 | url="URL TO AZURE BLOB OBJECT" 13 | ) 14 | 15 | input_result = bitcodin.create_input(input_obj) 16 | 17 | video_configs = list() 18 | 19 | video_configs.append(bitcodin.VideoStreamConfig( 20 | default_stream_id=0, 21 | bitrate=4800000, 22 | profile='Main', 23 | preset='premium', 24 | height=1080, 25 | width=1920 26 | )) 27 | video_configs.append(bitcodin.VideoStreamConfig( 28 | default_stream_id=0, 29 | bitrate=2400000, 30 | profile='Main', 31 | preset='premium', 32 | height=768, 33 | width=1024 34 | )) 35 | video_configs.append(bitcodin.VideoStreamConfig( 36 | default_stream_id=0, 37 | bitrate=1200000, 38 | profile='Main', 39 | preset='premium', 40 | height=480, 41 | width=854 42 | )) 43 | 44 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 45 | 46 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 47 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 48 | 49 | manifests = ['mpd', 'm3u8'] 50 | 51 | job = bitcodin.Job( 52 | input_id=input_result.input_id, 53 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 54 | manifest_types=manifests, 55 | speed='standard' 56 | ) 57 | job_result = bitcodin.create_job(job) 58 | 59 | while job_result.status != 'Finished' and job_result.status != 'Error': 60 | job_result = bitcodin.get_job(job_result.job_id) 61 | print(job_result.to_json()) 62 | sleep(5) 63 | 64 | print(job_result.to_json()) 65 | print("Job Finished!") 66 | -------------------------------------------------------------------------------- /examples/create_job_closed_captions_multiple_audio_streams.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | __author__ = 'David Moser - david.moser@bitmovin.net' 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://url.to.video.with.closed.captions') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [ 39 | bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000), 40 | bitcodin.AudioStreamConfig(default_stream_id=1, bitrate=192000) 41 | ] 42 | 43 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile Closed Captions', video_configs, audio_configs) 44 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 45 | 46 | manifests = ['mpd', 'm3u8'] 47 | 48 | audio_meta_data = [ 49 | bitcodin.AudioMetaData(0, 'Spanish', 'es'), 50 | bitcodin.AudioMetaData(1, 'English', 'en') 51 | ] 52 | 53 | video_meta_data = [ 54 | bitcodin.VideoMetaData(0, 'Spanish', 'es') 55 | ] 56 | 57 | job = bitcodin.Job( 58 | input_id=input_result.input_id, 59 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 60 | manifest_types=manifests, 61 | speed='standard', 62 | extract_closed_captions=True, 63 | audio_meta_data=audio_meta_data, 64 | video_meta_data=video_meta_data 65 | ) 66 | 67 | job_result = bitcodin.create_job(job) 68 | -------------------------------------------------------------------------------- /examples/create_job_cropping_video.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | import sys 6 | 7 | bitcodin.api_key = 'YOUR API KEY' 8 | 9 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 10 | input_result = bitcodin.create_input(input_obj) 11 | 12 | video_configs = list() 13 | 14 | video_configs.append(bitcodin.VideoStreamConfig( 15 | default_stream_id=0, 16 | bitrate=4500000, 17 | profile='Main', 18 | preset='premium', 19 | height=818, 20 | width=1920 21 | )) 22 | video_configs.append(bitcodin.VideoStreamConfig( 23 | default_stream_id=0, 24 | bitrate=2400000, 25 | profile='Main', 26 | preset='premium', 27 | height=544, 28 | width=1280 29 | )) 30 | video_configs.append(bitcodin.VideoStreamConfig( 31 | default_stream_id=0, 32 | bitrate=1000000, 33 | profile='Main', 34 | preset='premium', 35 | height=362, 36 | width=854 37 | )) 38 | video_configs.append(bitcodin.VideoStreamConfig( 39 | default_stream_id=0, 40 | bitrate=500000, 41 | profile='Main', 42 | preset='premium', 43 | height=272, 44 | width=640 45 | )) 46 | 47 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000, rate=48000)] 48 | 49 | cropping_config = bitcodin.CroppingConfig( 50 | top=100, 51 | bottom=100, 52 | left=236, 53 | right=236 54 | ) 55 | 56 | encoding_profile_obj = bitcodin.EncodingProfile( 57 | name='Cropping Profile', 58 | video_stream_configs=video_configs, 59 | audio_stream_configs=audio_configs, 60 | cropping_config=cropping_config 61 | ) 62 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 63 | 64 | manifests = ['mpd', 'm3u8'] 65 | 66 | job = bitcodin.Job( 67 | input_id=input_result.input_id, 68 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 69 | manifest_types=manifests, 70 | speed='standard' 71 | ) 72 | 73 | try: 74 | job_result = bitcodin.create_job(job) 75 | except Exception, e: 76 | print('Could not start job: %s' % e.message) 77 | print('API Response: %s' % e.error) 78 | sys.exit() 79 | 80 | while job_result.status != 'Finished' and job_result.status != 'Error': 81 | job_result = bitcodin.get_job(job_result.job_id) 82 | print(job_result.to_json()) 83 | sleep(5) 84 | 85 | print(job_result.to_json()) 86 | print("Job Finished!") 87 | -------------------------------------------------------------------------------- /examples/create_job_deinterlace.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | import sys 6 | 7 | bitcodin.api_key = '' 8 | 9 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 10 | input_result = bitcodin.create_input(input_obj) 11 | 12 | video_configs = list() 13 | 14 | 15 | video_configs.append(bitcodin.VideoStreamConfig( 16 | default_stream_id=0, 17 | bitrate=4500000, 18 | profile='Main', 19 | preset='premium', 20 | height=818, 21 | width=1920 22 | )) 23 | video_configs.append(bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=2400000, 26 | profile='Main', 27 | preset='premium', 28 | height=544, 29 | width=1280 30 | )) 31 | video_configs.append(bitcodin.VideoStreamConfig( 32 | default_stream_id=0, 33 | bitrate=1000000, 34 | profile='Main', 35 | preset='premium', 36 | height=362, 37 | width=854 38 | )) 39 | video_configs.append(bitcodin.VideoStreamConfig( 40 | default_stream_id=0, 41 | bitrate=500000, 42 | profile='Main', 43 | preset='premium', 44 | height=272, 45 | width=640 46 | )) 47 | 48 | 49 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000, rate=48000)] 50 | 51 | encoding_profile_obj = bitcodin.EncodingProfile( 52 | name='API Test Profile', 53 | video_stream_configs=video_configs, 54 | audio_stream_configs=audio_configs 55 | ) 56 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 57 | 58 | manifests = ['mpd', 'm3u8'] 59 | 60 | job = bitcodin.Job( 61 | input_id=input_result.input_id, 62 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 63 | manifest_types=manifests, 64 | speed='standard', 65 | deinterlace=True 66 | ) 67 | 68 | try: 69 | job_result = bitcodin.create_job(job) 70 | except Exception, e: 71 | print('Could not start job: %s' % e.message) 72 | print('API Response: %s' % e.error) 73 | sys.exit() 74 | 75 | while job_result.status != 'Finished' and job_result.status != 'Error': 76 | job_result = bitcodin.get_job(job_result.job_id) 77 | print(job_result.to_json()) 78 | sleep(5) 79 | 80 | print(job_result.to_json()) 81 | print("Job Finished!") 82 | -------------------------------------------------------------------------------- /examples/create_job_encrypted_dash_and_hls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | bitcodin.api_key = 'YOUR API KEY' 6 | 7 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 8 | input_result = bitcodin.create_input(input_obj) 9 | 10 | video_configs = list() 11 | 12 | video_configs.append(bitcodin.VideoStreamConfig( 13 | default_stream_id=0, 14 | bitrate=4800000, 15 | profile='Main', 16 | preset='premium', 17 | height=1080, 18 | width=1920 19 | )) 20 | video_configs.append(bitcodin.VideoStreamConfig( 21 | default_stream_id=0, 22 | bitrate=2400000, 23 | profile='Main', 24 | preset='premium', 25 | height=768, 26 | width=1024 27 | )) 28 | video_configs.append(bitcodin.VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=1200000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=854 35 | )) 36 | 37 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=128000)] 38 | 39 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 40 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 41 | 42 | manifests = ['mpd', 'm3u8'] 43 | 44 | drm_config = bitcodin.PlayreadyWidevineCombinedDrmConfig( 45 | key='100b6c20940f779a4589152b57d2dacb', 46 | pssh='CAESEOtnarvLNF6Wu89hZjDxo9oaDXdpZGV2aW5lX3Rlc3QiEGZrajNsamFTZGZhbGtyM2oqAkhEMgA=', 47 | kid='eb676abbcb345e96bbcf616630f1a3da', 48 | la_url='http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&ContentKey=EAtsIJQPd5pFiRUrV9Layw==', 49 | method='mpeg_cenc' 50 | ) 51 | 52 | hls_encryption_config = bitcodin.HLSEncryptionConfig( 53 | key='cab5b529ae28d5cc5e3e7bc3fd4a544d', 54 | method='SAMPLE-AES', 55 | iv='08eecef4b026deec395234d94218273d' 56 | ) 57 | 58 | job = bitcodin.Job( 59 | input_id=input_result.input_id, 60 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 61 | manifest_types=manifests, 62 | speed='standard', 63 | drm_config=drm_config, 64 | hls_encryption_config=hls_encryption_config 65 | ) 66 | 67 | job_result = bitcodin.create_job(job) 68 | -------------------------------------------------------------------------------- /examples/create_job_fairplay_encryption.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | bitcodin.api_key = 'YOUR API KEY' 6 | 7 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 8 | input_result = bitcodin.create_input(input_obj) 9 | 10 | video_configs = list() 11 | 12 | video_configs.append(bitcodin.VideoStreamConfig( 13 | default_stream_id=0, 14 | bitrate=4800000, 15 | profile='Main', 16 | preset='premium', 17 | height=1080, 18 | width=1920 19 | )) 20 | video_configs.append(bitcodin.VideoStreamConfig( 21 | default_stream_id=0, 22 | bitrate=2400000, 23 | profile='Main', 24 | preset='premium', 25 | height=768, 26 | width=1024 27 | )) 28 | video_configs.append(bitcodin.VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=1200000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=854 35 | )) 36 | 37 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 38 | 39 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 40 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 41 | 42 | manifests = ['mpd', 'm3u8'] 43 | 44 | hls_encryption_config = bitcodin.HLSEncryptionConfig( 45 | key='cab5b529ae28d5cc5e3e7bc3fd4a544d', 46 | method='FAIRPLAY', 47 | iv='08eecef4b026deec395234d94218273d', 48 | uri='skd://userspecifc?custom=information' 49 | ) 50 | 51 | job = bitcodin.Job( 52 | input_id=input_result.input_id, 53 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 54 | manifest_types=manifests, 55 | speed='standard', 56 | hls_encryption_config=hls_encryption_config 57 | ) 58 | 59 | job_result = bitcodin.create_job(job) 60 | -------------------------------------------------------------------------------- /examples/create_job_get_manifest_info.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 39 | 40 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 41 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 42 | 43 | manifests = ['mpd', 'm3u8'] 44 | 45 | job = bitcodin.Job( 46 | input_id=input_result.input_id, 47 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 48 | manifest_types=manifests, 49 | speed='standard' 50 | ) 51 | job_result = bitcodin.create_job(job) 52 | 53 | while job_result.status != 'Finished' and job_result.status != 'Error': 54 | job_result = bitcodin.get_job(job_result.job_id) 55 | print(job_result.to_json()) 56 | sleep(5) 57 | 58 | print("Job Finished!") 59 | 60 | manifest_info = bitcodin.get_manifest_info(job_result.job_id) 61 | print("Manifest Information:") 62 | print(manifest_info.to_json()) 63 | -------------------------------------------------------------------------------- /examples/create_job_hevc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 39 | 40 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 41 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 42 | 43 | manifests = ['mpd', 'm3u8'] 44 | 45 | job = bitcodin.Job( 46 | input_id=input_result.input_id, 47 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 48 | manifest_types=manifests 49 | ) 50 | job_result = bitcodin.create_job(job) 51 | 52 | while job_result.status != 'Finished' and job_result.status != 'Error': 53 | job_result = bitcodin.get_job(job_result.job_id) 54 | print(job_result.to_json()) 55 | sleep(5) 56 | 57 | print(job_result.to_json()) 58 | print("Job Finished!") 59 | -------------------------------------------------------------------------------- /examples/create_job_hls_encryption.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | bitcodin.api_key = 'YOUR API KEY' 6 | 7 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 8 | input_result = bitcodin.create_input(input_obj) 9 | 10 | video_configs = list() 11 | 12 | video_configs.append(bitcodin.VideoStreamConfig( 13 | default_stream_id=0, 14 | bitrate=4800000, 15 | profile='Main', 16 | preset='premium', 17 | height=1080, 18 | width=1920 19 | )) 20 | video_configs.append(bitcodin.VideoStreamConfig( 21 | default_stream_id=0, 22 | bitrate=2400000, 23 | profile='Main', 24 | preset='premium', 25 | height=768, 26 | width=1024 27 | )) 28 | video_configs.append(bitcodin.VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=1200000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=854 35 | )) 36 | 37 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 38 | 39 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 40 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 41 | 42 | manifests = ['mpd', 'm3u8'] 43 | 44 | hls_encryption_config = bitcodin.HLSEncryptionConfig( 45 | key='cab5b529ae28d5cc5e3e7bc3fd4a544d', 46 | method='SAMPLE-AES', 47 | iv='08eecef4b026deec395234d94218273d' 48 | ) 49 | 50 | job = bitcodin.Job( 51 | input_id=input_result.input_id, 52 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 53 | manifest_types=manifests, 54 | speed='standard', 55 | hls_encryption_config=hls_encryption_config 56 | ) 57 | 58 | job_result = bitcodin.create_job(job) 59 | -------------------------------------------------------------------------------- /examples/create_job_keep_aspect_ratio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'INSERT YOUR API KEY HERE' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | print("INPUT REQUEST: %s\n\n" % input_obj.to_json()) 10 | input_result = bitcodin.create_input(input_obj) 11 | print("INPUT RESULT: %s\n\n" % input_result.to_json()) 12 | 13 | video_configs = list() 14 | 15 | # If height and width are given, aspect ratio will not be kept 16 | video_configs.append(bitcodin.VideoStreamConfig( 17 | default_stream_id=0, 18 | bitrate=4800000, 19 | profile='Main', 20 | preset='premium', 21 | height=600, 22 | width=1920 23 | )) 24 | 25 | # If only width or only height is provided aspect ratio will be determined automatically 26 | video_configs.append(bitcodin.VideoStreamConfig( 27 | default_stream_id=0, 28 | bitrate=2400000, 29 | profile='Main', 30 | preset='premium', 31 | width=1024 32 | )) 33 | video_configs.append(bitcodin.VideoStreamConfig( 34 | default_stream_id=0, 35 | bitrate=1200000, 36 | profile='Main', 37 | preset='premium', 38 | height=720 39 | )) 40 | 41 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 42 | 43 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 44 | print("ENCODING PROFILE REQUEST %s\n\n" % encoding_profile_obj.to_json()) 45 | 46 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 47 | print("ENCODING PROFILE RESULT %s\n\n" % encoding_profile_result.to_json()) 48 | 49 | manifests = ['mpd', 'm3u8'] 50 | 51 | job = bitcodin.Job( 52 | input_id=input_result.input_id, 53 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 54 | manifest_types=manifests, 55 | speed='premium' 56 | ) 57 | print("JOB: %s" % job.to_json()) 58 | 59 | job_result = bitcodin.create_job(job) 60 | while job_result.status != 'Finished' and job_result.status != 'Error': 61 | job_result = bitcodin.get_job(job_result.job_id) 62 | print(job_result.to_json()) 63 | sleep(5) 64 | 65 | print(job_result.to_json()) 66 | print("Job Finished!") -------------------------------------------------------------------------------- /examples/create_job_location.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | bitcodin.api_key = 'YOUR API KEY' 6 | 7 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 8 | input_result = bitcodin.create_input(input_obj) 9 | 10 | video_configs = list() 11 | 12 | video_configs.append(bitcodin.VideoStreamConfig( 13 | default_stream_id=0, 14 | bitrate=4800000, 15 | profile='Main', 16 | preset='premium', 17 | height=1080, 18 | width=1920 19 | )) 20 | video_configs.append(bitcodin.VideoStreamConfig( 21 | default_stream_id=0, 22 | bitrate=2400000, 23 | profile='Main', 24 | preset='premium', 25 | height=768, 26 | width=1024 27 | )) 28 | video_configs.append(bitcodin.VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=1200000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=854 35 | )) 36 | 37 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 38 | 39 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 40 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 41 | 42 | manifests = ['mpd', 'm3u8'] 43 | 44 | job = bitcodin.Job( 45 | input_id=input_result.input_id, 46 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 47 | manifest_types=manifests, 48 | speed='standard', 49 | location='europe' 50 | ) 51 | 52 | job_result = bitcodin.create_job(job) 53 | -------------------------------------------------------------------------------- /examples/create_job_merge_audio_channels.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/at_test/mono_streams.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [ 39 | bitcodin.AudioStreamConfig( 40 | default_stream_id=0, 41 | bitrate=192000 42 | ) 43 | ] 44 | 45 | encoding_profile_obj = bitcodin.EncodingProfile('Merge Audio Channels Profile', video_configs, audio_configs) 46 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 47 | 48 | # Merge all 6 audio channels into one 49 | merge_audio_channel_config = bitcodin.MergeAudioChannelConfig([1, 2, 3, 4, 5, 6]) 50 | merge_audio_channel_configs = [merge_audio_channel_config] 51 | 52 | manifests = ['mpd', 'm3u8'] 53 | 54 | # Audio merging is only available with speed standard 55 | job = bitcodin.Job( 56 | input_id=input_result.input_id, 57 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 58 | manifest_types=manifests, 59 | speed='standard', 60 | merge_audio_channel_configs=merge_audio_channel_configs 61 | ) 62 | job_result = bitcodin.create_job(job) 63 | 64 | while job_result.status != 'Finished' and job_result.status != 'Error': 65 | job_result = bitcodin.get_job(job_result.job_id) 66 | print(job_result.to_json()) 67 | sleep(5) 68 | 69 | print(job_result.to_json()) 70 | print("Job Finished!") 71 | -------------------------------------------------------------------------------- /examples/create_job_mp3_audio_only.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/audiosample.mp3') 9 | print("INPUT REQUEST: %s\n\n" % input_obj.to_json()) 10 | input_result = bitcodin.create_input(input_obj) 11 | print("INPUT RESULT: %s\n\n" % input_result.to_json()) 12 | 13 | video_configs = list() 14 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 15 | 16 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 17 | print("ENCODING PROFILE REQUEST %s\n\n" % encoding_profile_obj.to_json()) 18 | 19 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 20 | print("ENCODING PROFILE RESULT %s\n\n" % encoding_profile_result.to_json()) 21 | 22 | manifests = ['mpd', 'm3u8'] 23 | 24 | job = bitcodin.Job( 25 | input_id=input_result.input_id, 26 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 27 | manifest_types=manifests, 28 | speed='standard' 29 | ) 30 | print("JOB: %s" % job.to_json()) 31 | 32 | job_result = bitcodin.create_job(job) 33 | while job_result.status != 'Finished' and job_result.status != 'Error': 34 | job_result = bitcodin.get_job(job_result.job_id) 35 | print(job_result.to_json()) 36 | sleep(5) 37 | 38 | print(job_result.to_json()) 39 | print("Job Finished!") 40 | 41 | -------------------------------------------------------------------------------- /examples/create_job_multiple_audio_streams.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | bitcodin.api_key = 'YOUR API KEY' 6 | 7 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-two-audio-streams-short.mkv') 8 | input_result = bitcodin.create_input(input_obj) 9 | 10 | video_configs = list() 11 | 12 | video_configs.append(bitcodin.VideoStreamConfig( 13 | default_stream_id=0, 14 | bitrate=4800000, 15 | profile='Main', 16 | preset='premium', 17 | height=1080, 18 | width=1920 19 | )) 20 | video_configs.append(bitcodin.VideoStreamConfig( 21 | default_stream_id=0, 22 | bitrate=2400000, 23 | profile='Main', 24 | preset='premium', 25 | height=768, 26 | width=1024 27 | )) 28 | video_configs.append(bitcodin.VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=1200000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=854 35 | )) 36 | 37 | audio_configs = list() 38 | audio_stream_config_0 = bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000) 39 | audio_stream_config_1 = bitcodin.AudioStreamConfig(default_stream_id=1, bitrate=192000) 40 | audio_configs.append(audio_stream_config_0) 41 | audio_configs.append(audio_stream_config_1) 42 | 43 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 44 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 45 | 46 | audio_meta_data = [] 47 | audio_stream_config_0_meta_data = bitcodin.AudioMetaData(0, 'de', 'Just Sound') 48 | audio_stream_config_1_meta_data = bitcodin.AudioMetaData(1, 'en', 'Sound and Voice') 49 | audio_meta_data.append(audio_stream_config_0_meta_data) 50 | audio_meta_data.append(audio_stream_config_1_meta_data) 51 | 52 | manifests = ['mpd', 'm3u8'] 53 | 54 | job = bitcodin.Job( 55 | input_id=input_result.input_id, 56 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 57 | manifest_types=manifests, 58 | speed='standard', 59 | audio_meta_data=audio_meta_data 60 | ) 61 | 62 | job_result = bitcodin.create_job(job) 63 | -------------------------------------------------------------------------------- /examples/create_job_playready_drm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | bitcodin.api_key = 'YOUR API KEY' 6 | 7 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 8 | input_result = bitcodin.create_input(input_obj) 9 | 10 | video_configs = list() 11 | video_configs.append(bitcodin.VideoStreamConfig( 12 | default_stream_id=0, 13 | bitrate=4800000, 14 | profile='Main', 15 | preset='premium', 16 | height=1080, 17 | width=1920 18 | )) 19 | video_configs.append(bitcodin.VideoStreamConfig( 20 | default_stream_id=0, 21 | bitrate=2400000, 22 | profile='Main', 23 | preset='premium', 24 | height=768, 25 | width=1024 26 | )) 27 | video_configs.append(bitcodin.VideoStreamConfig( 28 | default_stream_id=0, 29 | bitrate=1200000, 30 | profile='Main', 31 | preset='premium', 32 | height=480, 33 | width=854 34 | )) 35 | 36 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 37 | 38 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 39 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 40 | 41 | manifests = ['mpd', 'm3u8'] 42 | 43 | drm_config = bitcodin.PlayreadyDrmConfig( 44 | k_id='746573745f69645f4639465043304e4f', 45 | key_seed='XVBovsmzhP9gRIZxWfFta3VVRPzVEWmJsazEJ46I', 46 | la_url='http://playready.directtaps.net/pr/svc/rightsmanager.asmx', 47 | method='mpeg_cenc' 48 | ) 49 | 50 | job = bitcodin.Job( 51 | input_id=input_result.input_id, 52 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 53 | manifest_types=manifests, 54 | speed='standard', 55 | drm_config=drm_config 56 | ) 57 | 58 | job_result = bitcodin.create_job(job) 59 | -------------------------------------------------------------------------------- /examples/create_job_rotation.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 39 | 40 | encoding_profile_obj = bitcodin.EncodingProfile( 41 | name='API Test Profile', 42 | video_stream_configs=video_configs, 43 | audio_stream_configs=audio_configs, 44 | rotation=45 45 | ) 46 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 47 | 48 | manifests = ['mpd', 'm3u8'] 49 | 50 | 51 | # Simply give a output_id to the job configuration to which the results should be copied when the job is finished. 52 | job = bitcodin.Job( 53 | input_id=input_result.input_id, 54 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 55 | manifest_types=manifests 56 | ) 57 | job_result = bitcodin.create_job(job) 58 | 59 | while job_result.status != 'Finished' and job_result.status != 'Error': 60 | job_result = bitcodin.get_job(job_result.job_id) 61 | print(job_result.to_json()) 62 | sleep(5) 63 | 64 | print(job_result.to_json()) 65 | print "Job Finished!" -------------------------------------------------------------------------------- /examples/create_job_s3_input.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.S3Input( 9 | access_key="YOUR ACCESS KEY", 10 | secret_key="YOUR SECRET KEY", 11 | host="AWS HOST", 12 | bucket="AWS BUCKET", 13 | region="AWS REGION", 14 | object_key="PATH TO OBJECT" 15 | ) 16 | 17 | input_result = bitcodin.create_input(input_obj) 18 | 19 | video_configs = list() 20 | 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=4800000, 24 | profile='Main', 25 | preset='premium', 26 | height=1080, 27 | width=1920 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=2400000, 32 | profile='Main', 33 | preset='premium', 34 | height=768, 35 | width=1024 36 | )) 37 | video_configs.append(bitcodin.VideoStreamConfig( 38 | default_stream_id=0, 39 | bitrate=1200000, 40 | profile='Main', 41 | preset='premium', 42 | height=480, 43 | width=854 44 | )) 45 | 46 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 47 | 48 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 49 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 50 | 51 | manifests = ['mpd', 'm3u8'] 52 | 53 | job = bitcodin.Job( 54 | input_id=input_result.input_id, 55 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 56 | manifest_types=manifests, 57 | speed='standard' 58 | ) 59 | job_result = bitcodin.create_job(job) 60 | 61 | while job_result.status != 'Finished' and job_result.status != 'Error': 62 | job_result = bitcodin.get_job(job_result.job_id) 63 | print(job_result.to_json()) 64 | sleep(5) 65 | 66 | print(job_result.to_json()) 67 | print("Job Finished!") 68 | -------------------------------------------------------------------------------- /examples/create_job_widevine_drm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | bitcodin.api_key = 'YOUR API KEY' 6 | 7 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 8 | input_result = bitcodin.create_input(input_obj) 9 | 10 | video_configs = list() 11 | 12 | video_configs.append(bitcodin.VideoStreamConfig( 13 | default_stream_id=0, 14 | bitrate=4800000, 15 | profile='Main', 16 | preset='premium', 17 | height=1080, 18 | width=1920 19 | )) 20 | video_configs.append(bitcodin.VideoStreamConfig( 21 | default_stream_id=0, 22 | bitrate=2400000, 23 | profile='Main', 24 | preset='premium', 25 | height=768, 26 | width=1024 27 | )) 28 | video_configs.append(bitcodin.VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=1200000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=854 35 | )) 36 | 37 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 38 | 39 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 40 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 41 | 42 | manifests = ['mpd', 'm3u8'] 43 | 44 | drm_config = bitcodin.WidevineDrmConfig( 45 | provider='widevine_test', 46 | signing_key='1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9', 47 | signing_iv='d58ce954203b7c9a9a9d467f59839249', 48 | request_url='http://license.uat.widevine.com/cenc/getcontentkey', 49 | content_id='746573745f69645f4639465043304e4f', 50 | method='mpeg_cenc' 51 | ) 52 | 53 | job = bitcodin.Job( 54 | input_id=input_result.input_id, 55 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 56 | manifest_types=manifests, 57 | speed='standard', 58 | drm_config=drm_config 59 | ) 60 | 61 | job_result = bitcodin.create_job(job) 62 | -------------------------------------------------------------------------------- /examples/create_job_widevine_playready_combined_drm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | bitcodin.api_key = 'YOUR API KEY' 6 | 7 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 8 | input_result = bitcodin.create_input(input_obj) 9 | 10 | video_configs = list() 11 | 12 | video_configs.append(bitcodin.VideoStreamConfig( 13 | default_stream_id=0, 14 | bitrate=4800000, 15 | profile='Main', 16 | preset='premium', 17 | height=1080, 18 | width=1920 19 | )) 20 | video_configs.append(bitcodin.VideoStreamConfig( 21 | default_stream_id=0, 22 | bitrate=2400000, 23 | profile='Main', 24 | preset='premium', 25 | height=768, 26 | width=1024 27 | )) 28 | video_configs.append(bitcodin.VideoStreamConfig( 29 | default_stream_id=0, 30 | bitrate=1200000, 31 | profile='Main', 32 | preset='premium', 33 | height=480, 34 | width=854 35 | )) 36 | 37 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 38 | 39 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 40 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 41 | 42 | manifests = ['mpd', 'm3u8'] 43 | 44 | drm_config = bitcodin.PlayreadyWidevineCombinedDrmConfig( 45 | key='100b6c20940f779a4589152b57d2dacb', 46 | pssh='CAESEOtnarvLNF6Wu89hZjDxo9oaDXdpZGV2aW5lX3Rlc3QiEGZrajNsamFTZGZhbGtyM2oqAkhEMgA=', 47 | kid='eb676abbcb345e96bbcf616630f1a3da', 48 | la_url='http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&ContentKey=EAtsIJQPd5pFiRUrV9Layw==', 49 | method='mpeg_cenc' 50 | ) 51 | 52 | job = bitcodin.Job( 53 | input_id=input_result.input_id, 54 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 55 | manifest_types=manifests, 56 | speed='standard', 57 | drm_config=drm_config 58 | ) 59 | 60 | job_result = bitcodin.create_job(job) 61 | -------------------------------------------------------------------------------- /examples/create_job_with_duration_and_start_time.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='https://s3-eu-west-1.amazonaws.com/bitbucketireland/Sintel-two-audio-streams.mkv') 9 | print("INPUT REQUEST: %s\n\n" % input_obj.to_json()) 10 | input_result = bitcodin.create_input(input_obj) 11 | print("INPUT RESULT: %s\n\n" % input_result.to_json()) 12 | 13 | video_configs = list() 14 | 15 | video_configs.append(bitcodin.VideoStreamConfig( 16 | default_stream_id=0, 17 | bitrate=4800000, 18 | profile='Main', 19 | preset='premium', 20 | height=1080, 21 | width=1920 22 | )) 23 | video_configs.append(bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=2400000, 26 | profile='Main', 27 | preset='premium', 28 | height=768, 29 | width=1024 30 | )) 31 | video_configs.append(bitcodin.VideoStreamConfig( 32 | default_stream_id=0, 33 | bitrate=1200000, 34 | profile='Main', 35 | preset='premium', 36 | height=480, 37 | width=854 38 | )) 39 | 40 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 41 | 42 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 43 | print("ENCODING PROFILE REQUEST %s\n\n" % encoding_profile_obj.to_json()) 44 | 45 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 46 | print("ENCODING PROFILE RESULT %s\n\n" % encoding_profile_result.to_json()) 47 | 48 | manifests = ['mpd', 'm3u8'] 49 | 50 | job = bitcodin.Job( 51 | input_id=input_result.input_id, 52 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 53 | manifest_types=manifests, 54 | speed='standard', 55 | duration=20, 56 | start_time=50 57 | ) 58 | print("JOB: %s" % job.to_json()) 59 | 60 | job_result = bitcodin.create_job(job) 61 | while job_result.status != 'Finished' and job_result.status != 'Error': 62 | job_result = bitcodin.get_job(job_result.job_id) 63 | print(job_result.to_json()) 64 | sleep(5) 65 | 66 | print(job_result.to_json()) 67 | print("Job Finished!") 68 | 69 | -------------------------------------------------------------------------------- /examples/create_job_with_specific_segment_length.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 39 | 40 | encoding_profile_obj = bitcodin.EncodingProfile( 41 | name='API Test Profile', 42 | video_stream_configs=video_configs, 43 | audio_stream_configs=audio_configs, 44 | segment_length=2 45 | ) 46 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 47 | 48 | manifests = ['mpd', 'm3u8'] 49 | 50 | 51 | # Simply give a output_id to the job configuration to which the results should be copied when the job is finished. 52 | job = bitcodin.Job( 53 | input_id=input_result.input_id, 54 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 55 | manifest_types=manifests 56 | ) 57 | job_result = bitcodin.create_job(job) 58 | 59 | while job_result.status != 'Finished' and job_result.status != 'Error': 60 | job_result = bitcodin.get_job(job_result.job_id) 61 | print(job_result.to_json()) 62 | sleep(5) 63 | 64 | print(job_result.to_json()) 65 | print("Job Finished!") 66 | -------------------------------------------------------------------------------- /examples/create_job_with_specific_video_audio_sample_rates.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000, rate=48000)] 39 | 40 | encoding_profile_obj = bitcodin.EncodingProfile( 41 | name='API Test Profile', 42 | video_stream_configs=video_configs, 43 | audio_stream_configs=audio_configs 44 | ) 45 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 46 | 47 | manifests = ['mpd', 'm3u8'] 48 | 49 | 50 | # Simply give a output_id to the job configuration to which the results should be copied when the job is finished. 51 | job = bitcodin.Job( 52 | input_id=input_result.input_id, 53 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 54 | manifest_types=manifests 55 | ) 56 | job_result = bitcodin.create_job(job) 57 | 58 | while job_result.status != 'Finished' and job_result.status != 'Error': 59 | job_result = bitcodin.get_job(job_result.job_id) 60 | print(job_result.to_json()) 61 | sleep(5) 62 | 63 | print(job_result.to_json()) 64 | print("Job Finished!") 65 | -------------------------------------------------------------------------------- /examples/create_job_with_transfer_to_s3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | print("INPUT REQUEST: %s\n\n" % input_obj.to_json()) 10 | input_result = bitcodin.create_input(input_obj) 11 | print("INPUT RESULT: %s\n\n" % input_result.to_json()) 12 | 13 | video_configs = list() 14 | 15 | video_configs.append(bitcodin.VideoStreamConfig( 16 | default_stream_id=0, 17 | bitrate=4800000, 18 | profile='Main', 19 | preset='premium', 20 | height=1080, 21 | width=1920 22 | )) 23 | video_configs.append(bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=2400000, 26 | profile='Main', 27 | preset='premium', 28 | height=768, 29 | width=1024 30 | )) 31 | video_configs.append(bitcodin.VideoStreamConfig( 32 | default_stream_id=0, 33 | bitrate=1200000, 34 | profile='Main', 35 | preset='premium', 36 | height=480, 37 | width=854 38 | )) 39 | 40 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 41 | 42 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 43 | print("ENCODING PROFILE REQUEST %s\n\n" % encoding_profile_obj.to_json()) 44 | 45 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 46 | print("ENCODING PROFILE RESULT %s\n\n" % encoding_profile_result.to_json()) 47 | 48 | manifests = ['mpd', 'm3u8'] 49 | 50 | job = bitcodin.Job( 51 | input_id=input_result.input_id, 52 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 53 | manifest_types=manifests, 54 | speed='standard' 55 | ) 56 | print("JOB: %s" % job.to_json()) 57 | 58 | job_result = bitcodin.create_job(job) 59 | while job_result.status != 'Finished' and job_result.status != 'Error': 60 | job_result = bitcodin.get_job(job_result.job_id) 61 | print(job_result.to_json()) 62 | sleep(5) 63 | 64 | print(job_result.to_json()) 65 | print("Job Finished!") 66 | 67 | output_obj = bitcodin.S3Output( 68 | name='MY S3 Output Profile', 69 | host='YOUR AWS HOST', 70 | access_key='YOUR AWS ACCESS KEY', 71 | secret_key='YOUR AWS SECRET KEY', 72 | bucket='YOUR AWS BUCKET NAME', 73 | prefix='PATH/TO/MY/DESIRED/OUTPUT/DESTINATION/', 74 | region='YOUR AWS REGION', 75 | make_public=False 76 | ) 77 | output_result = bitcodin.create_output(output_obj) 78 | 79 | print("Transferring job...") 80 | transfer_job = bitcodin.transfer_job(job_result.job_id, output_result.output_id) 81 | print("Transfer Job created: %s" % transfer_job) 82 | 83 | print("Show transfer jobs...") 84 | transfer_jobs = bitcodin.list_transfer_jobs(job_result.job_id) 85 | for transfer in transfer_jobs: 86 | print("Transfer Job: %s" % transfer.to_json()) 87 | -------------------------------------------------------------------------------- /examples/create_job_with_transmuxing.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'INSERT YOUR API KEY HERE' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | print("INPUT REQUEST: %s\n\n" % input_obj.to_json()) 10 | input_result = bitcodin.create_input(input_obj) 11 | print("INPUT RESULT: %s\n\n" % input_result.to_json()) 12 | 13 | video_configs = list() 14 | 15 | video_configs.append(bitcodin.VideoStreamConfig( 16 | default_stream_id=0, 17 | bitrate=4800000, 18 | profile='Main', 19 | preset='premium', 20 | height=1080, 21 | width=1920 22 | )) 23 | video_configs.append(bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=2400000, 26 | profile='Main', 27 | preset='premium', 28 | height=768, 29 | width=1024 30 | )) 31 | video_configs.append(bitcodin.VideoStreamConfig( 32 | default_stream_id=0, 33 | bitrate=1200000, 34 | profile='Main', 35 | preset='premium', 36 | height=480, 37 | width=854 38 | )) 39 | 40 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 41 | 42 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 43 | print("ENCODING PROFILE REQUEST %s\n\n" % encoding_profile_obj.to_json()) 44 | 45 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 46 | print("ENCODING PROFILE RESULT %s\n\n" % encoding_profile_result.to_json()) 47 | 48 | manifests = ['mpd', 'm3u8'] 49 | 50 | job = bitcodin.Job( 51 | input_id=input_result.input_id, 52 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 53 | manifest_types=manifests, 54 | speed='premium' 55 | ) 56 | print("JOB: %s" % job.to_json()) 57 | 58 | job_result = bitcodin.create_job(job) 59 | while job_result.status != 'Finished' and job_result.status != 'Error': 60 | job_result = bitcodin.get_job(job_result.job_id) 61 | print(job_result.to_json()) 62 | sleep(5) 63 | 64 | print(job_result.to_json()) 65 | print("Job Finished!") 66 | 67 | print("Create transmuxing job!") 68 | transmuxing_config = bitcodin.TransmuxingConfig( 69 | job_result.job_id, 70 | job_result.encoding_profiles[0].video_stream_configs[0].representation_id, 71 | [job_result.encoding_profiles[0].audio_stream_configs[0].representation_id] 72 | ) 73 | 74 | transmuxing_result = bitcodin.create_transmuxing(transmuxing_config) 75 | print("TRANSMUXING_JOB: %s\n\n" % transmuxing_result.to_json()) 76 | 77 | while transmuxing_result.status != 'finished' and transmuxing_result.status != 'error': 78 | transmuxing_result = bitcodin.get_transmuxing(transmuxing_result.id) 79 | print(transmuxing_result.to_json()) 80 | sleep(5) 81 | 82 | print ("Transmuxing finished!\nUrl to file: %s" % transmuxing_result.output_url) 83 | 84 | -------------------------------------------------------------------------------- /examples/create_job_with_watermark.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | import sys 6 | 7 | bitcodin.api_key = '' 8 | 9 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 10 | input_result = bitcodin.create_input(input_obj) 11 | 12 | video_configs = list() 13 | 14 | 15 | video_configs.append(bitcodin.VideoStreamConfig( 16 | default_stream_id=0, 17 | bitrate=4500000, 18 | profile='Main', 19 | preset='premium', 20 | height=818, 21 | width=1920 22 | )) 23 | video_configs.append(bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=2400000, 26 | profile='Main', 27 | preset='premium', 28 | height=544, 29 | width=1280 30 | )) 31 | video_configs.append(bitcodin.VideoStreamConfig( 32 | default_stream_id=0, 33 | bitrate=1000000, 34 | profile='Main', 35 | preset='premium', 36 | height=362, 37 | width=854 38 | )) 39 | video_configs.append(bitcodin.VideoStreamConfig( 40 | default_stream_id=0, 41 | bitrate=500000, 42 | profile='Main', 43 | preset='premium', 44 | height=272, 45 | width=640 46 | )) 47 | 48 | 49 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000, rate=48000)] 50 | 51 | watermark_config = bitcodin.WatermarkConfig( 52 | image_url='https://bitdash-a.akamaihd.net/webpages/bitcodin/images/bitcodin_transparent_50_1600.png', 53 | top=191, 54 | right=159 55 | ) 56 | 57 | encoding_profile_obj = bitcodin.EncodingProfile( 58 | name='API Test Profile', 59 | video_stream_configs=video_configs, 60 | audio_stream_configs=audio_configs, 61 | watermark_config=watermark_config 62 | ) 63 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 64 | 65 | manifests = ['mpd', 'm3u8'] 66 | 67 | job = bitcodin.Job( 68 | input_id=input_result.input_id, 69 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 70 | manifest_types=manifests, 71 | speed='standard' 72 | ) 73 | 74 | try: 75 | job_result = bitcodin.create_job(job) 76 | except Exception, e: 77 | print('Could not start job: %s' % e.message) 78 | print('API Response: %s' % e.error) 79 | sys.exit() 80 | 81 | while job_result.status != 'Finished' and job_result.status != 'Error': 82 | job_result = bitcodin.get_job(job_result.job_id) 83 | print(job_result.to_json()) 84 | sleep(5) 85 | 86 | print(job_result.to_json()) 87 | print("Job Finished!") 88 | -------------------------------------------------------------------------------- /examples/create_sprite.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | # Set your API key 6 | bitcodin.api_key = 'INSERT YOUR API KEY' 7 | 8 | # Create an input 9 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 10 | input_result = bitcodin.create_input(input_obj) 11 | 12 | # Create encoding profile 13 | video_configs = list() 14 | 15 | video_configs.append(bitcodin.VideoStreamConfig( 16 | default_stream_id=0, 17 | bitrate=4800000, 18 | profile='Main', 19 | preset='premium', 20 | height=1080, 21 | width=1920 22 | )) 23 | video_configs.append(bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=2400000, 26 | profile='Main', 27 | preset='premium', 28 | height=768, 29 | width=1024 30 | )) 31 | video_configs.append(bitcodin.VideoStreamConfig( 32 | default_stream_id=0, 33 | bitrate=1200000, 34 | profile='Main', 35 | preset='premium', 36 | height=480, 37 | width=854 38 | )) 39 | 40 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 41 | 42 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 43 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 44 | 45 | manifests = ['mpd', 'm3u8'] 46 | 47 | # Create a job 48 | job = bitcodin.Job( 49 | input_id=input_result.input_id, 50 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 51 | manifest_types=manifests 52 | ) 53 | job_result = bitcodin.create_job(job) 54 | print("Job created!") 55 | 56 | # Create a sprite with a height of 240px, a width of 320 every 5 seconds from a given job 57 | # Note: You don't have to create a new job for a sprite, you can use finished jobs too. 58 | sprite_request = bitcodin.SpriteRequest(job_id=job_result.job_id, height=240, width=320, distance=5) 59 | sprite = bitcodin.create_sprite(sprite_request) 60 | 61 | print("Sprite generated!\nURL to sprite jpg: %s\n" % sprite.sprite_url) 62 | print("Sprite generated!\nURL to sprite vtt: %s\n" % sprite.vtt_url) 63 | 64 | -------------------------------------------------------------------------------- /examples/create_thumbnail.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import bitcodin 4 | 5 | # Set your API key 6 | bitcodin.api_key = 'INSERT YOUR API KEY' 7 | 8 | # Create an input 9 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 10 | input_result = bitcodin.create_input(input_obj) 11 | 12 | # Create encoding profile 13 | video_configs = list() 14 | 15 | video_configs.append(bitcodin.VideoStreamConfig( 16 | default_stream_id=0, 17 | bitrate=4800000, 18 | profile='Main', 19 | preset='premium', 20 | height=1080, 21 | width=1920 22 | )) 23 | video_configs.append(bitcodin.VideoStreamConfig( 24 | default_stream_id=0, 25 | bitrate=2400000, 26 | profile='Main', 27 | preset='premium', 28 | height=768, 29 | width=1024 30 | )) 31 | video_configs.append(bitcodin.VideoStreamConfig( 32 | default_stream_id=0, 33 | bitrate=1200000, 34 | profile='Main', 35 | preset='premium', 36 | height=480, 37 | width=854 38 | )) 39 | 40 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 41 | 42 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 43 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 44 | 45 | manifests = ['mpd', 'm3u8'] 46 | 47 | # Create a job 48 | job = bitcodin.Job( 49 | input_id=input_result.input_id, 50 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 51 | manifest_types=manifests 52 | ) 53 | job_result = bitcodin.create_job(job) 54 | print("Job created!") 55 | 56 | # Create a thumbnail at second 50 with a height of 320px from a given job 57 | # Note: You don't have to create a new job for a thumbnail, you can use finished jobs too. 58 | thumbnail_request = bitcodin.ThumbnailRequest(job_id=job_result.job_id, height=320, position=50) 59 | thumbnail = bitcodin.create_thumbnail(thumbnail_request) 60 | 61 | print("Thumbnail generated!\nURL to thumbnail: %s\n" % thumbnail.thumbnail_url) 62 | 63 | -------------------------------------------------------------------------------- /examples/create_vtt_mpd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from time import sleep 3 | 4 | import bitcodin 5 | 6 | bitcodin.api_key = 'YOUR API KEY' 7 | 8 | input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv') 9 | input_result = bitcodin.create_input(input_obj) 10 | 11 | video_configs = list() 12 | 13 | video_configs.append(bitcodin.VideoStreamConfig( 14 | default_stream_id=0, 15 | bitrate=4800000, 16 | profile='Main', 17 | preset='premium', 18 | height=1080, 19 | width=1920 20 | )) 21 | video_configs.append(bitcodin.VideoStreamConfig( 22 | default_stream_id=0, 23 | bitrate=2400000, 24 | profile='Main', 25 | preset='premium', 26 | height=768, 27 | width=1024 28 | )) 29 | video_configs.append(bitcodin.VideoStreamConfig( 30 | default_stream_id=0, 31 | bitrate=1200000, 32 | profile='Main', 33 | preset='premium', 34 | height=480, 35 | width=854 36 | )) 37 | 38 | audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)] 39 | 40 | encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs) 41 | encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj) 42 | 43 | manifests = ['mpd', 'm3u8'] 44 | 45 | job = bitcodin.Job( 46 | input_id=input_result.input_id, 47 | encoding_profile_id=encoding_profile_result.encoding_profile_id, 48 | manifest_types=manifests 49 | ) 50 | job_result = bitcodin.create_job(job) 51 | print("Started Job with id %d\n" % job_result.job_id) 52 | 53 | while job_result.status != 'Finished' and job_result.status != 'Error': 54 | job_result = bitcodin.get_job(job_result.job_id) 55 | print(job_result.to_json()) 56 | sleep(5) 57 | 58 | 59 | subtitles = list() 60 | sub_de = bitcodin.VttSubTitle('de', 'Deutsch', 'http://your.url/to/de_sub.vtt') 61 | sub_eng = bitcodin.VttSubTitle('eng', 'English', 'http://your.url/to/eng_sub.vtt') 62 | subtitles.append(sub_de) 63 | subtitles.append(sub_eng) 64 | 65 | vtt_mpd_request = bitcodin.VttMpdRequest(job_result.job_id, subtitles) 66 | 67 | res = bitcodin.create_vtt_mpd(vtt_mpd_request) 68 | print(res.mpd_url) 69 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests==2.4.3 2 | coveralls==0.5 3 | coverage==3.7.1 4 | testtools -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup( 4 | name='bitcodin', 5 | description='Python interface for bitcodin API', 6 | version='1.6.9', 7 | author='David Moser, Dominic Miglar', 8 | author_email='david.moser@bitmovin.net, dominic.miglar@bitmovin.net', 9 | packages=['bitcodin'], 10 | include_package_data=True, 11 | url='https://github.com/bitmovin/bitcodin-python', 12 | install_requires=[ 13 | 'requests>=2.4.3' 14 | ], 15 | classifiers=[ 16 | 'Development Status :: 4 - Beta', 17 | 'Intended Audience :: Developers', 18 | 'Programming Language :: Python :: 2.7', 19 | 'Programming Language :: Python :: 3.4', 20 | ] 21 | ) 22 | 23 | --------------------------------------------------------------------------------