如何将转码后的文件上传到s3并创建链接以下载

时间:2016-08-22 21:39:03

标签: ruby-on-rails ruby amazon-s3 ffmpeg

我想在我的模块"创建"之后下载视频。它通过组合图片和音频文件。输出转到我的tmp文件夹。这有效,但我不知道如何访问它。

我的方法是创建另一个名为"转换"的回形针附件。负责转码的模块也应负责将转换后的视频上传到存储桶,然后我可以通过@upload.converted.url访问它。

我不知道怎么回事,我的眼睛因为搜索而受伤。如果您有更好的方式让我能够在没有此选项的情况下下载转码后的视频,我将对此持开放态度。

模块 - > videocreatingproccessor.rb:

 require 'streamio-ffmpeg'
 require 'fileutils'

 module VideoCreatingProcessor

 def self.convert_to_video (path_to_audio_file, path_to_image_file)
 movie = FFMPEG::Movie.new(path_to_audio_file)
 options = {video_codec: "libx264", frame_rate: 60, resolution: "960x720",
       x264_vprofile: "high", x264_preset: "slow", pixel_format: "720p",
       audio_codec: "libfaac", audio_bitrate: 32, audio_sample_rate: 44100, audio_channels: 2,
       threads: 2}
  woptions = { watermark: path_to_image_file, resolution: "960x720", watermark_filter: { padding_x: 10, padding_y: 10 } }

 movie.transcode("tmp/output.mp4",woptions ,options )
 end

uploads_controller.rb:

 class UploadsController < ApplicationController
 before_action :set_upload, only: [:show, :edit, :update, :destroy]

 def index
 @uploads = Upload.all
 end

 def paudioaddress
 "https:" + @upload.audio.url
 end

 def pimageaddress
 "https:" + @upload.image.url
  end

  def show
  require "video_creating_processor"
  newvideo =    VideoCreatingProcessor.convert_to_video(paudioaddress,pimageaddress)
  end

  ....
  end

0 个答案:

没有答案