Class: Mediakit::Initializers::FFmpeg::FormatInitializer

Inherits:
Base
  • Object
show all
Defined in:
lib/mediakit/initializers/ffmpeg.rb

Constant Summary collapse

DELIMITER_FOR_FORMATS =
"\n --\n".freeze
SUPPORT_PATTERN =
/(?<support>(?<demuxing>[D.\s])(?<muxing>[E.\s]))/.freeze
PATTERN =
/\A\s*#{SUPPORT_PATTERN}\s+(?<name>\w+)\s+(?<desc>.+)\z/.freeze

Instance Attribute Summary

Attributes inherited from Base

#items

Instance Method Summary collapse

Methods inherited from Base

#call, #initialize, #parse_items

Constructor Details

This class inherits a constructor from Mediakit::Initializers::FFmpeg::Base

Instance Method Details

#create_item(line) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mediakit/initializers/ffmpeg.rb', line 67

def create_item(line)
  match = line.match(PATTERN)
  if match
    attributes = {
      name: match[:name],
      desc: match[:desc],
      demuxing: match[:demuxing] == 'D',
      muxing: match[:muxing] == 'E'
    }
    Mediakit::FFmpeg::Format.create_constant(
      "FORMAT_#{attributes[:name].underscore.upcase}", attributes
    )
  end
end

#item_typeObject



56
57
58
# File 'lib/mediakit/initializers/ffmpeg.rb', line 56

def item_type
  'formats'
end

#raw_itemsObject



60
61
62
63
64
65
# File 'lib/mediakit/initializers/ffmpeg.rb', line 60

def raw_items
  options = Mediakit::FFmpeg::Options.new(Mediakit::FFmpeg::Options::GlobalOption.new('formats' => true))
  output = @command.run(options, logger: nil)
  return [] if output.nil? || output.empty?
  output.split(DELIMITER_FOR_FORMATS)[1].each_line.to_a
end