Class: UEncode::VideoStreams

Inherits:
Object
  • Object
show all
Defined in:
lib/uencode/elements.rb

Overview

VideoStreams represents the audio and video streams for a single output

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVideoStreams

Returns a new instance of VideoStreams.



308
309
310
311
# File 'lib/uencode/elements.rb', line 308

def initialize
  @video_config = VideoConfig.new
  @audio_config = AudioConfig.new
end

Instance Attribute Details

#audio_configObject (readonly)

Returns the value of attribute audio_config.



305
306
307
# File 'lib/uencode/elements.rb', line 305

def audio_config
  @audio_config
end

#video_configObject (readonly)

Returns the value of attribute video_config.



305
306
307
# File 'lib/uencode/elements.rb', line 305

def video_config
  @video_config
end

Instance Method Details

#audioObject



352
353
354
# File 'lib/uencode/elements.rb', line 352

def audio
  @audio_config
end

#configure(hash) ⇒ Object

Configures the transcoding using a nested hash with the following format:

config = {:video => { ... }, :audio => { ... }

The keys for the “video” hash can be any of the following: bitrate, codec, cbr, crop, deinterlace, framerate, height, keyframe_interval, maxbitrate, par, profile, passes, stretch, width.

The keys for the :audio hash can be any of the following: codec, bitrate, channels, samplerate.



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/uencode/elements.rb', line 324

def configure(hash)
  vid = hash[:video]
  aud = hash[:audio]      
  if !vid.nil?
    configure_video do |c|
      vid.each_pair { |key, value| c.send("#{key}=", value)}
    end
  end

  if !aud.nil?
    configure_audio do |c|
      aud.each_pair { |key, value| c.send("#{key}=", value) }
    end
  end
end

#configure_audio {|@audio_config| ... } ⇒ Object

Yields:



344
345
346
# File 'lib/uencode/elements.rb', line 344

def configure_audio
  yield @audio_config
end

#configure_video {|@video_config| ... } ⇒ Object

Yields:



340
341
342
# File 'lib/uencode/elements.rb', line 340

def configure_video
  yield @video_config
end

#to_xmlObject



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/uencode/elements.rb', line 356

def to_xml
  %Q{
      <video>
        #{!video.bitrate.nil? ? '<bitrate>' + video.bitrate.to_s + '</bitrate>' : ""}
        #{!video.codec.nil? ? '<codec>' + video.codec + '</codec>' : ""}
        #{!video.profile.nil? ? '<profile>' + video.profile + '</profile>' : ""}
        #{!video.quality.nil? ? '<quality>' + video.quality.to_s + '</quality>' : ""}
        #{!video.framerate.nil? ? '<framerate>' + video.framerate.to_s + '</framerate>' : ""}
        #{!@video_config.size.nil? ? @video_config.size.to_xml : ""}
        #{@video_config.max_size ? @video_config.max_size.to_xml : ""}
        #{video.passes.nil? ? "" : '<passes>' + video.passes.to_s + '</passes>'}
        #{video.deinterlace.nil? ? "" : '<deinterlace>' + video.deinterlace.to_s + '</deinterlace>'}
        #{video.fix_rotation.nil? ? "" : '<fix_rotation>' + video.fix_rotation.to_s + '</fix_rotation>'}
        #{video.force_square_pixels.nil? ? "" : '<force_square_pixels>' + video.force_square_pixels.to_s + '</force_square_pixels>'}
      </video>
      <audio>
        #{audio.codec.nil? ? "" : '<codec>' + audio.codec + '</codec>'}
        #{audio.bitrate.nil? ? "" : '<bitrate>' + audio.bitrate.to_s + '</bitrate>'}
        #{audio.channels.nil? ? "" : '<channels>' + audio.channels.to_s + '</channels>'}
        #{audio.samplerate.nil? ? "" : '<samplerate>' + audio.samplerate.to_s + '</samplerate>'}
        #{audio.quality.nil? ? "" : '<quality>' + video.quality.to_s + '</quality>'}                        
      </audio>
  }
end

#videoObject



348
349
350
# File 'lib/uencode/elements.rb', line 348

def video
  @video_config
end