Witam,
Mam problem z uploadem filmów, w logach w konsoli żadnych błędów nie pokazuję, od razu jest rollback.
Spróbowałem jednak przez rails console dodać film i jest takie coś.
irb(main):009:0> m.movie_dir = File.open(’/home/bartek/Pobrane/v1.mp4’)
I, [2016-05-22T12:23:09.938535 #10940] INFO – : Running transcoding…
/usr/bin/ffmpeg -y -i /home/bartek/Pulpit/wthr_srvice-master/public/uploads/tmp/1463912589-10940-0001-8599/v1.mp4 -vcodec libx264 -acodec aac -s 640x360 -strict experimental -q:v 5 -preset slow -g 30 -aspect 1.7777777777777777 /home/bartek/Pulpit/wthr_srvice-master/public/uploads/tmp/1463912589-10940-0001-8599/tmpfile.mp4
I, [2016-05-22T12:24:28.102630 #10940] INFO – : Transcoding of /home/bartek/Pulpit/wthr_srvice-master/public/uploads/tmp/1463912589-10940-0001-8599/v1.mp4 to /home/bartek/Pulpit/wthr_srvice-master/public/uploads/tmp/1463912589-10940-0001-8599/tmpfile.mp4 succeeded
=> #<File:/home/bartek/Pobrane/v1.mp4>
irb(main):010:0> m.save!
(0.3ms) begin transaction
(0.2ms) rollback transaction
ActiveRecord::RecordInvalid: Validation failed: Movie dir Failed to transcode with FFmpeg. Check ffmpeg install and verify video is not corrupt or cut short. Original error: undefined method `success=’ for #Movie:0x007fc9a02e86e8
I tutaj nie za bardzo rozumiem o co chodzi
Movie.rb
class Movie < ActiveRecord::Base
belongs_to :user
has_one :subject
mount_uploader :movie_dir, VideoUploader
def set_success(format, opts)
self.success = true
end
end
VideoUploader
class VideoUploader < CarrierWave::Uploader::Base
include CarrierWave::Video
Include RMagick or MiniMagick support:
include CarrierWave::RMagick
include CarrierWave::MiniMagick
process encode_video: [:mp4, audio_codec: “aac”, :custom => “-strict experimental -q:v 5 -preset slow -g 30”, callbacks: { after_transcode: :set_success } ]
Choose what kind of storage to use for this uploader:
storage :file
storage :fog
version :mp4 do
def full_filename(for_file)
super.chomp(File.extname(super)) + ‘.mp4’
end
endOverride the directory where uploaded files will be stored.
This is a sensible default for uploaders that are meant to be mounted:
def store_dir
“uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}”
end
new.html.erb
<%= form_for @movie, :url => users_movies_path, html: { :multipart => true} do |f| %>
<div class="form-group"> <%= f.label :movie_name %> <br /> <%= f.text_field :movie_name %> </div>
<div class="form-group"> <%= f.label :subject_id %> <br /> <%= f.collection_select(:subject_id, Subject.all, :id, :subject_name) %> </div>
<div class="form-group"> <%= f.label :movie_dir %> <br /> <%= f.file_field :movie_dir %> </div> <div class="actions"> <%= f.submit "Upload Video" %> </div>
<% end %>