Skip to Content Skip to Search

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.

Methods
A
M

Class Public methods

accept?(blob)

# File activestorage/lib/active_storage/analyzer/audio_analyzer.rb, line 13
def self.accept?(blob)
  blob.audio?
end

Instance Public methods

metadata()

# File activestorage/lib/active_storage/analyzer/audio_analyzer.rb, line 17
def metadata
  { duration: duration, bit_rate: bit_rate }.compact
end