Class: ActiveStorage::Analyzer::AudioAnalyzer
- Inherits:
-
ActiveStorage::Analyzer
- Object
- ActiveStorage::Analyzer
- ActiveStorage::Analyzer::AudioAnalyzer
- Defined in:
- lib/active_storage/analyzer/audio_analyzer.rb
Overview
Extracts duration (seconds) and bit_rate (bits/s) from an audio blob.
Example:
ActiveStorage::Analyzer::AudioAnalyzer.new(blob).
# => { duration: 5.0, bit_rate: 320340 }
This analyzer requires the FFmpeg system library, which is not provided by Rails.
Instance Attribute Summary
Attributes inherited from ActiveStorage::Analyzer
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ActiveStorage::Analyzer
Constructor Details
This class inherits a constructor from ActiveStorage::Analyzer
Class Method Details
.accept?(blob) ⇒ Boolean
13 14 15 |
# File 'lib/active_storage/analyzer/audio_analyzer.rb', line 13 def self.accept?(blob) blob.audio? end |
Instance Method Details
#metadata ⇒ Object
17 18 19 |
# File 'lib/active_storage/analyzer/audio_analyzer.rb', line 17 def { duration: duration, bit_rate: bit_rate }.compact end |