Module: FlyAdmin::Screenshotable

Extended by:
ActiveSupport::Concern
Defined in:
app/models/fly_admin/concerns/screenshotable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#create_thumbnailObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/fly_admin/concerns/screenshotable.rb', line 11

def create_thumbnail
  movie = FFMPEG::Movie.new(self.full_source_path)
  screenshot_path = "public/uploads/video/picture/#{self.uuid}/screenshot.jpg"
  create_dir screenshot_path

  seek_time = self.thumb_time.present? ? self.thumb_time : (movie.duration / 2).to_s
  self.thumb_time = seek_time

  system("ffmpeg -ss #{seek_time} -y -i #{self.full_source_path.shellescape} -vframes 1 -f image2 #{screenshot_path}")

end

#picture_urlObject

needed in videos#show



7
8
9
# File 'app/models/fly_admin/concerns/screenshotable.rb', line 7

def picture_url
   "/uploads/video/picture/#{self.identifier}/screenshot.jpg"
end

#remove_pictureObject



23
24
25
# File 'app/models/fly_admin/concerns/screenshotable.rb', line 23

def remove_picture
  FileUtils.rm(Rails.root.to_s + "/public" + picture_url)
end