Friday, 27 September 2013

carrierwave-video error: nil is not a symbol

carrierwave-video error: nil is not a symbol

I'm using the carrierwave-video gem to upload videos using my Rails app.
When I try to upload a video, I get the following error:
Failed to transcode with FFmpeg. Check ffmpeg install and verify video is
not corrupt or cut short. Original error: nil is not a symbol.
I believe that my ffmpeg installation was successful because if I can run
the following command successfully:
qt-faststart input.mp4 output.mp4
Looking more closely at my logs, it seems like the parameters for the
video file are correct, but I have two rollbacks when the app tries to
create a video record:
Started POST "/videos" for 127.0.0.1 at 2013-09-27 11:42:04 -0400
Processing by VideosController#create as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"5lMoFtM5Rrdu4Ra8ut8rD3jYv3FJ0cxo38QW5ATw9ZQ=",
"video"=>{"project_id"=>"4", "step_id"=>"22", "saved"=>"true",
"embed_url"=>"",
"video_path"=>#<ActionDispatch::Http::UploadedFile:0x007f84702436b8
@original_filename="2013-08-02 17.19.02.mp4", @content_type="video/mp4",
@headers="Content-Disposition: form-data; name=\"video[video_path]\";
filename=\"2013-08-02 17.19.02.mp4\"\r\nContent-Type: video/mp4\r\n",
@tempfile=#<File:/var/folders/dc/c0nfvwy96lq7p4ll94mklnmr0000gp/T/RackMultipart20130927-1871-173l2g7>>},
"button"=>""}
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1
LIMIT 1
Project Load (0.3ms) SELECT "projects".* FROM "projects" WHERE
"projects"."id" = $1 LIMIT 1 [["id", "4"]]
(0.2ms) BEGIN
(0.2ms) ROLLBACK
(0.2ms) BEGIN
(0.1ms) ROLLBACK
#<ActiveModel::Errors:0x007f847058fd08 @base=#<Video id: nil, embed_url:
"", project_id: 4, step_id: 22, saved: true, created_at: nil, updated_at:
nil, thumbnail_url: nil, image_id: nil, video_path: nil>,
@messages={:video_path=>["Failed to transcode with FFmpeg. Check ffmpeg
install and verify video is not corrupt or cut short. Original error: nil
is not a symbol"]}>
Completed 406 Not Acceptable in 616ms (ActiveRecord: 1.6ms)
Has anyone had a similar problem, and if so, how did you solve it?
Video.rb:
class Video < ActiveRecord::Base
# maybe we should add a title attribute to the video?
attr_accessible :position, :project_id, :step_id, :image_id, :saved,
:embed_url, :thumbnail_url, :video_path
mount_uploader :video_path, VideoPathUploader
...
def set_success(format, opt)
self.success = true
end
end
video_path_uploader.rb
class VideoPathUploader < CarrierWave::Uploader::Base
include CarrierWave::Video
include CarrierWave::Video::Thumbnailer
process encode_video: [:mp4, callbacks: { after_transcode: :set_success } ]
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
# storage :file
storage :fog
# Override 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
version :thumb do
process thumbnail: [{format: 'png', quality: 10, size: 158, strip:
false, logger: Rails.logger}]
def full_filename for_file
png_name for_file, version_name
end
end
version :square_thumb do
process thumbnail: [{format: 'png', quality: 10, size: 105, strip:
false, logger: Rails.logger}]
def full_filename for_file
png_name for_file, version_name
end
end
end

No comments:

Post a Comment