I was wondering if anyone can help me with this issue.
I need help to find a way to make paperclip work with elastic transcoder.
I need to be able to save an uploaded video in S3 Amazon bucket using paperclip and then transcode the uploaded video into 3 different format and save them back in the same bucket.
The issue is can I get all done together?
This issue has been solved by using a gem called 'elastic_transcoder'
Here is a sample of what I have done using elastic_transcoder
First get the url of the video you want to transcode excluding the AWS domain name
and bucket name
.
url = self.paperclip_video.url.split('/').pop
url = url.drop(3).join('/')
you got the idea the above code varies depending on the url you get you just need the path as I said before excluding the AWS domain name
and bucket name
.
Then get the path to the original video
input_url = url + '/' + self.paperclip_video_file_name
Then get the filename
excluding the extension to user to generate the output url
for the transcoded video
file_name = File.basename(self.paperclip_video_file_name, File.extname(self.paperclip_video_file_name))
Then create the output path
output_url = url + '/mp4_' + file_name + '.mp4'
For simplicity I am transcoding to one type which is mp4
Create a new elastic transcoding pipline
pipeline = ElasticTranscoder::Pipeline.new
please note that you need to set first the pipeline on you AWS
account moreover you need to set your preset
for mp4
conversion on your AWS account
.
Initialize your pipline object
by passing your pipeline_id
which you obtained from AWS
pipeline_front.pipeline '***************'
create a new Jobs
object to pass you transcoding jobs to
jobs = ElasticTranscoder::Jobs.new
create new Job
jobs.create_job input_url, output_url, "**your pipeline_id**", "your preset_id", "#{url}/web_thumbnail-{count}"
This will do the job and you can get the video transcoded.