Class: Mediakit::Initializers::FFmpeg::DecoderInitializer

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

Constant Summary collapse

DELIMITER_FOR_CODER =
"\n ------\n".freeze
SUPPORT_PATTERN =

Encoders: V.…. = Video A.…. = Audio S.…. = Subtitle .F.… = Frame-level multithreading ..S… = Slice-level multithreading …X.. = Codec is experimental .…B. = Supports draw_horiz_band .….D = Supports direct rendering method 1


/(?<support>(?<type>[VAS.])(?<frame_level>[F.])(?<slice_level>[S.])(?<experimental>[X.])(?<horizon_band>[B.])(?<direct_rendering_method>[D.]))/.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



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/mediakit/initializers/ffmpeg.rb', line 109

def create_item(line)
  match =  line.match(PATTERN)
  if match
    attributes = {
      name: match[:name],
      desc: match[:desc],
      frame_level: match[:frame_level] != '.',
      slice_level: match[:slice_level] != '.',
      experimental: match[:experimental] != '.',
      horizon_band: match[:horizon_band] != '.',
      direct_rendering_method: match[:direct_rendering_method] != '.'
    }
    case match[:type]
    when 'V'
      Mediakit::FFmpeg::VideoDecoder.create_constant(
        "DECODER_#{attributes[:name].underscore.upcase}", attributes.merge(type: :video)
      )
    when 'A'
      Mediakit::FFmpeg::AudioDecoder.create_constant(
        "DECODER_#{attributes[:name].underscore.upcase}", attributes.merge(type: :audio)
      )
    when 'S'
      Mediakit::FFmpeg::SubtitleDecoder.create_constant(
        "DECODER_#{attributes[:name].underscore.upcase}", attributes.merge(type: :subtitle)
      )
    else
      raise(UnknownTypeError)
    end
  end
end

#item_typeObject



98
99
100
# File 'lib/mediakit/initializers/ffmpeg.rb', line 98

def item_type
  'decoders'
end

#raw_itemsObject



102
103
104
105
106
107
# File 'lib/mediakit/initializers/ffmpeg.rb', line 102

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