W3cubDocs

/Ruby on Rails 7.0

class ActiveStorage::Analyzer::AudioAnalyzer

Parent:
ActiveStorage::Analyzer

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.

Public Class Methods

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

Public Instance Methods

metadata() Show source
# 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.