Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release/v1.4.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Moser committed Mar 3, 2016
2 parents 2e5b2dd + 8194e0a commit 444fbe6
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@
## 1.4.6
* Changed preset to premium
* Adjusted encoding profile quality o examples

## 1.4.7
* Added keep aspect ratio feature and test
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.6
1.4.7
10 changes: 7 additions & 3 deletions bitcodin/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,17 @@ def __init__(self, name, video_stream_configs, audio_stream_configs, rotation=0,

class VideoStreamConfig(BitcodinObject):

def __init__(self, default_stream_id, bitrate, profile, preset, height, width, rate=None, codec=None):
def __init__(self, default_stream_id, bitrate, profile, preset, height=None, width=None, rate=None, codec=None):
self.defaultStreamId = default_stream_id
self.bitrate = bitrate
self.profile = profile
self.preset = preset
self.height = height
self.width = width

if height is not None:
self.height = height

if width is not None:
self.width = width

if rate is not None:
self.rate = rate
Expand Down
2 changes: 2 additions & 0 deletions bitcodin/test/job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from .testcase_create_job_deinterlace import CreateJobWithDeinterlacing
from .testcase_create_job_mp3_audio_only import CreateJobAudioOnlyTestCase
from bitcodin.test.job.testcase_create_thumbnail import CreateThumbnailTestCase
from bitcodin.test.job.testcase_create_job_keep_aspect_ratio import CreateJobKeepAspectRatioTestCase


def get_test_suite():
Expand Down Expand Up @@ -74,5 +75,6 @@ def get_test_suite():
test_suite.addTest(CreateJobWithDeinterlacing())
test_suite.addTest(CreateJobAudioOnlyTestCase)
test_suite.addTest(CreateThumbnailTestCase)
test_suite.addTest(CreateJobKeepAspectRatioTestCase)

return test_suite
74 changes: 74 additions & 0 deletions bitcodin/test/job/testcase_create_job_keep_aspect_ratio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
__author__ = 'David Moser <david.moser@bitmovin.com>'

import unittest
from bitcodin import create_job
from bitcodin import create_input
from bitcodin import create_encoding_profile
from bitcodin import delete_input
from bitcodin import delete_encoding_profile
from bitcodin import Job
from bitcodin import Input
from bitcodin import AudioStreamConfig
from bitcodin import VideoStreamConfig
from bitcodin import EncodingProfile
from bitcodin.test.config import test_video_url
from bitcodin.test.bitcodin_test_case import BitcodinTestCase


class CreateJobKeepAspectRatioTestCase(BitcodinTestCase):
def setUp(self):
super(CreateJobKeepAspectRatioTestCase, self).setUp()
input_url = test_video_url
input = Input(input_url)
self.input = create_input(input)
video_configs = list()

video_configs.append(VideoStreamConfig(
default_stream_id=0,
bitrate=4800000,
profile='Main',
preset='premium',
height=600,
width=1920
))
video_configs.append(VideoStreamConfig(
default_stream_id=0,
bitrate=2400000,
profile='Main',
preset='premium',
width=1024
))
video_configs.append(VideoStreamConfig(
default_stream_id=0,
bitrate=1200000,
profile='Main',
preset='premium',
height=720
))

audio_stream_config = AudioStreamConfig(default_stream_id=0, bitrate=192000)

encoding_profile = EncodingProfile('API Test Profile', video_configs, [audio_stream_config])
self.encoding_profile = create_encoding_profile(encoding_profile)
self.manifests = ['m3u8', 'mpd']

def runTest(self):
job = Job(
input_id=self.input.input_id,
encoding_profile_id=self.encoding_profile.encoding_profile_id,
manifest_types=self.manifests
)
self.job = create_job(job)
self.assertEquals(self.job.input.input_id, job.inputId)
self.assertEquals(self.job.input.url, self.input.url)
self.assertEquals(self.job.encoding_profiles[0].encoding_profile_id, job.encodingProfileId)
self.wait_until_job_finished(self.job.job_id)

def tearDown(self):
delete_input(self.input.input_id)
delete_encoding_profile(self.encoding_profile.encoding_profile_id)
super(CreateJobTestCase, self).tearDown()


if __name__ == '__main__':
unittest.main()
66 changes: 66 additions & 0 deletions examples/create_job_keep_aspect_ratio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python
from time import sleep

import bitcodin

bitcodin.api_key = 'INSERT YOUR API KEY HERE'

input_obj = bitcodin.Input(url='http://bitbucketireland.s3.amazonaws.com/Sintel-original-short.mkv')
print("INPUT REQUEST: %s\n\n" % input_obj.to_json())
input_result = bitcodin.create_input(input_obj)
print("INPUT RESULT: %s\n\n" % input_result.to_json())

video_configs = list()

# If height and width are given, aspect ratio will not be kept
video_configs.append(bitcodin.VideoStreamConfig(
default_stream_id=0,
bitrate=4800000,
profile='Main',
preset='premium',
height=600,
width=1920
))

# If only width or only height is provided aspect ratio will be determined automatically
video_configs.append(bitcodin.VideoStreamConfig(
default_stream_id=0,
bitrate=2400000,
profile='Main',
preset='premium',
width=1024
))
video_configs.append(bitcodin.VideoStreamConfig(
default_stream_id=0,
bitrate=1200000,
profile='Main',
preset='premium',
height=720
))

audio_configs = [bitcodin.AudioStreamConfig(default_stream_id=0, bitrate=192000)]

encoding_profile_obj = bitcodin.EncodingProfile('API Test Profile', video_configs, audio_configs)
print("ENCODING PROFILE REQUEST %s\n\n" % encoding_profile_obj.to_json())

encoding_profile_result = bitcodin.create_encoding_profile(encoding_profile_obj)
print("ENCODING PROFILE RESULT %s\n\n" % encoding_profile_result.to_json())

manifests = ['mpd', 'm3u8']

job = bitcodin.Job(
input_id=input_result.input_id,
encoding_profile_id=encoding_profile_result.encoding_profile_id,
manifest_types=manifests,
speed='premium'
)
print("JOB: %s" % job.to_json())

job_result = bitcodin.create_job(job)
while job_result.status != 'Finished' and job_result.status != 'Error':
job_result = bitcodin.get_job(job_result.job_id)
print(job_result.to_json())
sleep(5)

print(job_result.to_json())
print("Job Finished!")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name='bitcodin',
description='Python interface for bitcodin API',
version='1.4.6',
version='1.4.7',
author='David Moser, Dominic Miglar',
author_email='david.moser@bitmovin.net, dominic.miglar@bitmovin.net',
packages=['bitcodin'],
Expand Down

0 comments on commit 444fbe6

Please sign in to comment.