how to upload a video to google driver use paperclip or carriwave - ruby-on-rails

i want to upload video to google driver.
code models
video model
class Video < ActiveRecord::Base
has_attached_file :video,
:storage => :google_drive,
:google_drive_credentials => {:client_id => AppConfig.gg_drive.client_id,
:client_secret => AppConfig.gg_drive.client_secret,
:refresh_token => AppConfig.gg_drive.refresh_token,
:scope => AppConfig.gg_drive.scope,
:access_token => Token.cache_access_token_google_drive
},
:styles => {
:medium => {
:geometry => "640x480",
:format => 'mp4'
},
:thumb => { :geometry => "160x120", :format => 'jpeg', :time => 10}
},# hello 123
:processors => [:transcoder],
:google_drive_options => {
:path => proc { |style| "#{style}_#{id}_#{image.original_filename}" },
:public_folder_id => '0B0VNyOkzIwUZZFFGeVhycFk0dnc'
}
end
in Gemfile
gem 'google-api-client'
gem 'paperclip'
gem 'paperclip-googledrive'
gem 'paperclip-av-transcoder'
gem "paperclip-ffmpeg"
in controller
def create
if params[:videos]
params[:videos].each { |video| Video.create(video: video) }
end
end
when i run , this display error
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
Av::UnableToDetect in AlbumsController#create
Unable to detect any supported library
pls. how to fix this errors

Related

URL issue: paperclip-av-transcoder

I am trying to implement paperclip-av-transcoder gem. I have checked everything but not able to find what I am doing wrong here. I'm writing steps which I have followed.
Added into gemfile
--> gem 'paperclip-av-transcoder'
Added into my model
--> has_attached_file :video_file, :styles => {
:medium => { :geometry => "640x480", :format => 'mp4' },
:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
}, :processors => [:transcoder]
--> validates_attachment_content_type :video_file, :content_type => /\Avideo\/.*\Z/
created schema to add column name
"video_file_meta"
In my view file
video_tag(video.video_file.url, controls: true, autobuffer: true, size: "320x240")
I have checked video in public/system folder it is properly saved I am able to see that video there but I am not able to see that in my view file.
Video Url -> /system/videos/video_files/000/000/003/original/tingtong_464.mp4?1497851104
I am sharing screens to show how it looks in the browser.
Everything from my point is correct, except Paperclip requires at least one field in database - *_file_name (for you it's video_file_file_name), but you didn't added it and Paperclip can't construct url properly. Read more https://github.com/thoughtbot/paperclip#usage
Currently working model file code:
has_attached_file :video_file, :styles => {
:medium => { :geometry => "500x500", :format => 'jpg' },
:thumb => { :geometry => "100x100", :format => 'jpg' }
}, :processors => [:transcoder]
validates_attachment_content_type :video_file,
:content_type => [
"video/mp4",
"video/quicktime",
"video/3gpp",
"video/x-ms-wmv",
"video/mov",
"video/flv",
],
:message => "Sorry! We do not accept the attached file type"
I guess I am not resizing my video file in any other video format so it is working properly.

getting random error while upload photo with paperclip on my ftp server

I used gem "paperclip" for upload images and gem "paperclip-storage-ftp" for store images on my own ftp server. It worked fine for a while, but now I am getting random errors, when I upload photos.
Sometimes this
Net::FTPReplyError - 150 Connecting to port 3270
Sometime this
Net::ReadTimeout - Net::ReadTimeout:
Sometime this
Paperclip::Storage::Ftp::NoServerAvailable
.. and sometimes this:
Net::FTPPermError - 500 ?
Model
class AlbumPhoto < ActiveRecord::Base
has_attached_file :photo, {
# Choose the FTP storage backend
:storage => :ftp,
:path => "www.abcd.com/:attachment/:id/:style/:filename",
:url => "ftp://abcd#domain.com#domain.com/www.abcd.com/:attachment/:id/:style/:filename",
:ftp_servers => [
{
:host => "domain.com",
:user => "abcd#domain.com",
:password => "abcd123",
:passive => true
}
],
:styles => { :medium => "300x300^", :thumb => "100x100^" ,:large => "400x400^"},
}
end
Why is this happening?

Error when uploading video to heroku

I am using the paperclip and paperclip-av-transcoder in my rails app and I have gotten to the point where I can upload videos locally. But when I try it in heroku I get this error. Av::UnableToDetect (Unable to detect any supported library):
I may have to add something to make it work with s3 but I had it working with images earlier so everything should be setup for s3.
This is the code in my model
class Classvideo < ActiveRecord::Base
belongs_to :user
has_attached_file :video, :styles => {
:medium => {:geometry => "640x480", :format => 'flv'},
:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
}, :processors => [:transcoder]
validates_attachment_content_type :video, :content_type => ["video/mp4", "video.mov", "video/mpeg","video/mpeg4", "image/jpg", "image/jpeg"]
end
Ok, you just need to install ffmpeg
For example on OS-X: http://www.renevolution.com/how-to-install-ffmpeg-on-mac-os-x/
And then on heroku https://elements.heroku.com/buildpacks/shunjikonishi/heroku-buildpack-ffmpeg
I had the same issue just this past week - Try this!
Video model:
has_attached_file :video, styles: {
:medium => {
:geometry => "640x480",
:format => 'mp4'
},
:thumb => { :geometry => "160x120", :format => 'jpeg', :time => 10}
}, :processors => [:transcoder]
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
Make sure you already bundled:
gem 'paperclip', '~> 4.3.1'
gem 'aws-sdk', '< 2.0'
gem 'paperclip-av-transcoder'
gem "paperclip-ffmpeg", "~> 1.2.0"
Run the paperclip migration:
rails g paperclip model video
Be sure to add in post_controller.rb:
private
def bscenes_params
params.require(:post).permit(:video)
end
Upload form:
<%= f.file_field :video %>
Show page:
<%= video_tag bscene.video.url(:medium), controls: true, style: "max-width: 100%;" %>
At this point you should get this error:
Av::UnableToDetect (Unable to detect any supported library):
Go to your terminal and type in:
brew options ffmpeg
Then run the following to install ffmpeg:
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools
Restart your server and try to upload a video now! Hope this helps - Happy coding :)

trouble with dots using rails paperclipftp

I got trouble with paperclipftp
Here my config :
has_attached_file :resume_img, :styles => { :thumb => "100x100#",:screen => '690x780#' },:retina => { :quality => 70 },
:path => "username.com/uploads/:attachment/:id/:style/:filename",
:url => "http://username.com/:attachment/:id/:style/:filename",
:storage => :ftp,
:ftp_credentials => { :host => 'ftp.username.com', :username => 'username', :password => '*******' },
:ftp_passive_mode => false,
:ftp_timeout => 90,
:ftp_verify_size_on_upload => false,
:ftp_debug_mode => false
My FTP is hosted by dreamhost, I need to upload inside the folder username.com but something strange appears rails escape the dots so it upload to usernamecom/uploads/
It does the same with the url it try to find the image at http://usernamecom/
Any idea???
Try it maybe escaped with
"username\.com/uploads/:attachment/:id/:style/:filename"

Paperclip CloudFiles?

How can I use Paperclip with CloudFiles? I found paperclip-cloudfiles, but in the description it says it will probably be removed and the last commit was in 2010.
Gemfile:
gem 'fog'
config/environments/production.rb
Paperclip::Attachment.default_options.update({
:path => ":picturable_name/:basename_:style.:extension",
:storage => :fog,
:fog_credentials => {
:provider => 'Rackspace',
:rackspace_username => RACKSPACE_USERNAME,
:rackspace_api_key => RACKSPACE_API_KEY,
:persistent => false
},
:fog_directory => CONTAINER_NAME,
:fog_public => true
})

Resources