-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathelastic_transcoder.rb
More file actions
80 lines (73 loc) · 1.89 KB
/
elastic_transcoder.rb
File metadata and controls
80 lines (73 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Set the following ENV variables:
# ENV['S3_BUCKET_NAME'],
# ENV['AWS_ACCESS_KEY_ID'],
# ENV['AWS_SECRET_ACCESS_KEY']
# ENV['AWS_REGION']
#
module ElasticTranscoder
class TranscodeVideo
require 'aws-sdk'
def initialize
@elastictranscoder = Aws::ElasticTranscoder::Client.new
end
# Creates a pipeline on AWS Elastic Transcoder
def create_pipeline name, input_bucket, output_bucket, role
begin
@elastictranscoder.create_pipeline(
name: name,
input_bucket: input_bucket,
output_bucket: output_bucket,
role: role
)
rescue
#Raise informative exception
end
end
# Deletes a pipeline on AWS Elastic Transcoder given an id
def delete_pipeline id
begin
@elastictranscoder.delete_pipeline(id: id)
rescue
#Raise informative exception
end
end
def create_job pipeline_id, preset_id, input_file, output_folder, output_file
@elastictranscoder.create_job(
pipeline_id: pipeline_id,
input: {
key: input_file,
},
outputs: [
{
key: output_file,
thumbnail_pattern: "thumb-{count}-{resolution}", #thumbnail generation based on pattern
preset_id: preset_id
}
],
output_key_prefix: output_folder
)
end
# List all pipelines
def list_pipelines
begin
@elastictranscoder.list_pipelines(ascending: "true")[:pipelines]
rescue
#Raise informative exception
end
end
def list_jobs id
begin
@elastictranscoder.list_jobs_by_pipeline(pipeline_id: id)[:jobs]
rescue
#Raise informative exception
end
end
def list_presets
begin
@elastictranscoder.list_presets[:presets]
rescue
#Raise informative exception
end
end
end
end