Extracts duration (seconds) and bit_rate (bits/s) from an audio blob.
Example:
ActiveStorage::Analyzer::AudioAnalyzer.new(blob).metadata # => { duration: 5.0, bit_rate: 320340 }
This analyzer requires the FFmpeg system library, which is not provided by Rails.
# File activestorage/lib/active_storage/analyzer/audio_analyzer.rb, line 13 def self.accept?(blob) blob.audio? end
# File activestorage/lib/active_storage/analyzer/audio_analyzer.rb, line 17 def metadata { duration: duration, bit_rate: bit_rate }.compact end
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.