Skip to content

Instantly share code, notes, and snippets.

@randika
Created September 2, 2015 14:36
Show Gist options
  • Select an option

  • Save randika/51062e0e3173ee91fec8 to your computer and use it in GitHub Desktop.

Select an option

Save randika/51062e0e3173ee91fec8 to your computer and use it in GitHub Desktop.
#### transcoder.rb ####
class Transcoder < Message
STATUS_SUBMITTED = "Submitted"
STATUS_PROGRESSING = "Progressing"
STATUS_COMPLETE = "Complete"
STATUS_CANCELED = "Canceled"
STATUS_ERROR = "Error"
def initialize(message)
@message = message
end
def create
uuid = UUID.new
transcode_job_uuid = uuid.generate
transcoder = Aws::ElasticTranscoder::Client.new(
:access_key_id => "YOUR_AWS_ACCESS_KEY_ID",
:secret_access_key => "YOUR_AWS_SECRET_ACCESS_KEY",
:region => "us-east-1")
#HLSV4
options = {
pipeline_id: "1432361831290-XXXXX",
input: {
key: "myfile.m4a"
},
outputs: [
{
key: "hls_64k",
preset_id: '1351620000001-200071',
segment_duration: "10"
}
],
playlists: [
{
name: "index",
format: "HLSv4",
output_keys: ["hls_64k"]
}
],
output_key_prefix: "hlsv4/#{@message.id}-#{transcode_job_uuid}/"
}
job = transcoder.create_job(options)
@message.update_attributes(
transcode_job_uuid: transcode_job_uuid,
transcode_job_id: job.data[:job][:id],
transcode_job_status: job.data[:job][:status],
state: Message::STATE_PUBLISHED)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment