Class: ActiveStorageValidations::Analyzer::VideoAnalyzer
- Inherits:
-
Analyzer
- Object
- Analyzer
- ActiveStorageValidations::Analyzer::VideoAnalyzer
- Includes:
- ActiveStorageValidations::ASVFFProbable
- Defined in:
- lib/active_storage_validations/analyzer/video_analyzer.rb
Overview
ActiveStorageValidations Video Analyzer
Extracts the following from a video attachable:
- Width (pixels)
- Height (pixels)
- Duration (seconds)
- Angle (degrees)
- Audio (true if file has an audio channel, false if not)
- Video (true if file has an video channel, false if not)
Example:
ActiveStorageValidations::Analyzer::VideoAnalyzer.new(attachable).
# => { width: 640, height: 480, duration: 5.0, angle: 0, audio: true, video: true }
When a video's angle is 90, -90, 270 or -270 degrees, its width and height are automatically swapped for convenience.
This analyzer requires the FFmpeg system library, which is not provided by Rails.
Instance Method Summary collapse
Instance Method Details
#metadata ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/active_storage_validations/analyzer/video_analyzer.rb', line 29 def read_media do |media| { width: (Integer(width) if width), height: (Integer(height) if height), duration: duration, angle: angle, audio: audio?, video: video? }.compact end end |