Class: ActiveStorage::Previewer::VideoPreviewer
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: | |
| Instance Chain: | |
| Inherits: | ActiveStorage::Previewer 
 | 
| Defined in: | activestorage/lib/active_storage/previewer/video_previewer.rb | 
Class Attribute Summary
- .ffmpeg_exists? ⇒ Boolean readonly
Class Method Summary
::ActiveStorage::Previewer - Inherited
Instance Attribute Summary
::ActiveStorage::Previewer - Inherited
Instance Method Summary
::ActiveStorage::Previewer - Inherited
| #preview | Override this method in a concrete subclass. | 
| #download_blob_to_tempfile | Downloads the blob to a tempfile on disk. | 
| #draw | Executes a system command, capturing its binary output in a tempfile. | 
| #logger, #tmpdir | |
Constructor Details
This class inherits a constructor from ActiveStorage::Previewer
Class Attribute Details
    .ffmpeg_exists?  ⇒ Boolean  (readonly)
  
  [ GitHub ]
# File 'activestorage/lib/active_storage/previewer/video_previewer.rb', line 12
def ffmpeg_exists? return @ffmpeg_exists unless @ffmpeg_exists.nil? @ffmpeg_exists = system(ffmpeg_path, "-version", out: File::NULL, err: File::NULL) end
Class Method Details
    .accept?(blob)  ⇒ Boolean 
  
# File 'activestorage/lib/active_storage/previewer/video_previewer.rb', line 8
def accept?(blob) blob.video? && ffmpeg_exists? end
.ffmpeg_path
[ GitHub ]# File 'activestorage/lib/active_storage/previewer/video_previewer.rb', line 18
def ffmpeg_path ActiveStorage.paths[:ffmpeg] || "ffmpeg" end
Instance Method Details
#preview(**options)
[ GitHub ]# File 'activestorage/lib/active_storage/previewer/video_previewer.rb', line 23
def preview(**) download_blob_to_tempfile do |input| draw_relevant_frame_from input do |output| yield io: output, filename: "#{blob.filename.base}.jpg", content_type: "image/jpeg", ** end end end