Class: Mediakit::Initializers::FFmpeg::EncoderInitializer
- 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
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
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/mediakit/initializers/ffmpeg.rb', line 167 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::VideoEncoder.create_constant( "ENCODER_#{attributes[:name].underscore.upcase}", attributes.merge(type: :video) ) when 'A' Mediakit::FFmpeg::AudioEncoder.create_constant( "ENCODER_#{attributes[:name].underscore.upcase}", attributes.merge(type: :audio) ) when 'S' Mediakit::FFmpeg::SubtitleEncoder.create_constant( "ENCODER_#{attributes[:name].underscore.upcase}", attributes.merge(type: :subtitle) ) else raise(UnknownTypeError) end end end |
#item_type ⇒ Object
156 157 158 |
# File 'lib/mediakit/initializers/ffmpeg.rb', line 156 def item_type 'encoders' end |
#raw_items ⇒ Object
160 161 162 163 164 165 |
# File 'lib/mediakit/initializers/ffmpeg.rb', line 160 def raw_items = Mediakit::FFmpeg::Options.new(Mediakit::FFmpeg::Options::GlobalOption.new('encoders' => true)) output = @command.run(, logger: nil) return [] if output.nil? || output.empty? output.split(DELIMITER_FOR_CODER)[1].each_line.to_a end |