Upload audio and videos by paperclip rails

Steps to Upload any type of media in ruby on rails by paperclip

1) Upload video

a) apply gem "paperclip-ffmpeg", "~> 1.0.1"

b) Apply validation in model

has_attached_file :video, :styles => {:medium => { :geometry => "300x300", :format => 'flv'},:thumb => {:geometry => "100x100#", :format => 'jpg', :time => 15}      }, :processors => [:ffmpeg] 
c) Install ffmpeg on your system
sudo apt-add-repository ppa:jon-severinsson/ffmpeg 
sudo apt-get update 
sudo apt-get install ffmpeg

d) Play video by using rails video_tag
video_tag("trailer.ogg", controls: true, autobuffer: true)
 or 
you can use 
gem 'jw_player_helper'
<%= video_player({:file => "/video/pf2011.flv", :image => "/video/pf2011.jpg"}) %>
This will play video in any format then you do not need to use any encoder.
2) Upload Audio

a) Simply use  gem "paperclip", "~> 3.0"
b) rails g paperclip audio
c) Write in model has_attached_file :audio
d)Apply validation 
 validates_attachment :audiocontent_type: { content_type: "media/x-wav" }
e) Play audio by using rails audio_tag
<%=audio_tag("sound.wav", autoplay: true, controls: true)%>

Post a Comment

1 comment:

  1. n audio might be troublesome because of foundation unsettling influence, poor chronicle quality, various speakers, loads of cross talking, speakers talking at an abnormally quick pace than typical and even complement of the speakersfrench transcription services

    ReplyDelete