edge badge

Extracts the following from a video blob:

  • Width (pixels)

  • Height (pixels)

  • Duration (seconds)

  • Angle (degrees)

  • Aspect ratio

Example:

ActiveStorage::VideoAnalyzer.new(blob).metadata
# => { width: 640, height: 480, duration: 5.0, angle: 0, aspect_ratio: [4, 3] }

This analyzer requires the ffmpeg system library, which is not provided by Rails. You must install ffmpeg yourself to use this analyzer.

Methods
A
M
Class Public methods
accept?(blob)
# File activestorage/lib/active_storage/analyzer/video_analyzer.rb, line 23
def self.accept?(blob)
  blob.video?
end
Instance Public methods
metadata()
# File activestorage/lib/active_storage/analyzer/video_analyzer.rb, line 27
def metadata
  { width: width, height: height, duration: duration, angle: angle, aspect_ratio: aspect_ratio }.compact
end