vendredi 15 janvier 2016

CarrierWave Video - Transcoding passes but video not uploading

The transaction to the server is being made, but as soon as the page refreshes, the server rolls back. My log file is below, and I will also post the contents of my video_uploader.rb Can you help me figure out why this issue is occurring. I've tried everything, and I'm unable to get the file to properly insert into the Db.

Started POST "/posts" for 127.0.0.1 at 2016-01-16 02:03:49 -0500
Processing by PostsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"iHJWGOeDdTsjnIgIQt3Ol+MClPMew17AoCqn16u9irctCh585IccUZ0Hri2XHQ9Y4Y2T6vEjhjPJXwVYGHyIJw==", "post"=>{"body"=>"Wow. This is clip is amazing, "video"=>#<ActionDispatch::Http::UploadedFile:0x3734328 @tempfile=#<Tempfile:C:/Users/Dave/AppData/Local/Temp/RackMultipart20160116-6892-1s8lgai.mp4>, @original_filename="Upload_Studio_4.mp4", @content_type="video/mp4", @headers="Content-Disposition: form-data; name=\"post[video]\"; filename=\"Upload_Studio_4.mp4\"\r\nContent-Type: video/mp4\r\n">}, "commit"=>"Post"}
  User Load (1.0ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 2]]
I, [2016-01-16T02:03:50.135302 #6892]  INFO -- : Running transcoding...
ffmpeg -y -i C:/Users/Dave/RubymineProjects/new_App/public/uploads/tmp/1452927829-6892-2770/Upload_Studio_4.mp4 -vcodec libx264 -acodec aac -s 300x168 -strict experimental -q:v 5 -preset slow -g 30  -aspect 1.7857142857142858 C:/Users/Dave/RubymineProjects/new_App/public/uploads/tmp/1452927829-6892-2770/tmpfile.mp4

I, [2016-01-16T02:03:58.557903 #6892]  INFO -- : Transcoding of C:/Users/Dave/RubymineProjects/new_app/public/uploads/tmp/1452927829-6892-2770/Upload_Studio_4.mp4 to C:/Users/Dave/RubymineProjects/new_App/public/uploads/tmp/1452927829-6892-2770/tmpfile.mp4 succeeded

   (0.0ms)  begin transaction
   (0.0ms)  rollback transaction
Redirected to http://127.0.0.1:3000/
Completed 302 Found in 9240ms (ActiveRecord: 1.0ms)

class VideoUploader < CarrierWave::Uploader::Base
  include CarrierWave::Video
  include CarrierWave::Video::Thumbnailer
  include CarrierWave::MiniMagick

  storage :file
  process encode_video: [:mp4, callbacks: { after_transcode: :set_success }, audio_codec: 'aac',:custom => '-strict experimental -q:v 5 -preset slow -g 30' , resolution: '300x500'],
  watermark: {
      path: File.join(Rails.root, 'app\public\images', 'logo.png'),
      position: :bottom_right,
      pixels_from_edge: 10
  }

  version :mp4 do
    def full_filename(for_file)
      super.chomp(File.extname(super)) + '.mp4'
    end
  end

  version :thumb do
    process thumbnail: [{format: 'png', quality: 10, size: 500, strip: true, logger: Rails.logger}]
    def full_filename(for_file)
      png_name for_file, version_name
    end
  end

  def png_name(for_file, version_name)
    %Q{#{version_name}_#{for_file.chomp(File.extname(for_file))}.png}
  end

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  def extension_white_list
    %w(mp4 mpeg)
  end
end

class Post < ActiveRecord::Base
 validates :video, presence: true
  mount_uploader :photo, PhotoUploader
  mount_uploader :video, VideoUploader

  def set_success(format, opts)
    self.success = true
  end
end

Aucun commentaire:

Enregistrer un commentaire