transcoder.rb is my file in Model
class Transcoder < Gallery
def initialize(video)
@gallery = video
end
def create
transcoder = AWS::ElasticTranscoder::Client.new(region: "Asia Pacific (Singapore)")
options = {
pipeline_id: "id_value",
input: {
key: @gallery.image,
frame_rate: "auto",
resolution: 'auto',
aspect_ratio: 'auto',
interlaced: 'auto',
container: 'auto'
},
outputs: [
{
key: "#{@filename}.avi",
preset_id: '1351620000001-000040',
rotate: "auto",
thumbnail_pattern: "{count}#{@filename}"
}
],
output_key_prefix: "#{@directory}"
}
job = transcoder.create_job(options)
@video.job_id = job.data[:job][:id]
@video.save!
end
end
And I am calling up the create method of Transcoder class in my create method of controller upon the action @gallery.save. Please note that here Gallery is the model which stores all the details about the video being uploaded to aws s3 bucket.