Django + AWS Elastic Transcoder
First, install dj_elastictranscode
with pip
$ pip install django-elastic-transcoder
Then, add dj_elastictranscoder
to INSTALLED_APPS
INSTALLED_APPS = (
...
'dj_elastictranscoder',
...
)
Bind urls.py
urlpatterns = patterns('',
...
url(r'^dj_elastictranscoder/', include('dj_elastictranscoder.urls')),
...
)
Migrate
$ ./manage.py migrate
- Create a new
Pipeline
in AWS Elastic Transcoder. - Hookup every Notification.
- Subscribe SNS Notification through HTTP
- You are ready to encode!
Please settings up variables below to make this app works.
AWS_ACCESS_KEY_ID = <your aws access key id>
AWS_SECRET_ACCESS_KEY = <your aws secret access key>
AWS_REGION = <aws region>
For instance, encode an mp3
from dj_elastictranscoder.transcoder import Transcoder
input = {
'Key': 'path/to/input.mp3',
}
outputs = [{
'Key': 'path/to/output.mp3',
'PresetId': '1351620000001-300040' # for example: 128k mp3 audio preset
}]
pipeline_id = '<pipeline_id>'
transcoder = Transcoder(pipeline_id)
transcoder.encode(input, outputs)
# Transcoder can also work standalone without Django
# just pass region and required aws key/secret to Transcoder, when initiate
transcoder = Transcoder(pipeline_id, AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)