class MultimediaParadise::Video::Resolution

Public Class Methods

new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/video/resolution.rb, line 24
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(i)
  run if run_already
end

Public Instance Methods

data?()
Alias for: dataset?
dataset?() click to toggle source
#

dataset?

#
# File lib/multimedia_paradise/video/resolution.rb, line 74
def dataset?
  @dataset
end
Also aliased as: data?
filter_dataset() click to toggle source
#

filter_dataset

#
# File lib/multimedia_paradise/video/resolution.rb, line 81
def filter_dataset
  @dataset = @dataset.split(N)
  @dataset.select! {|entry| entry.include? 'Stream ' }
  @dataset.select! {|entry| entry.include?('x') and entry.include?('Video:') }
end
grab_resolution_from_the_dataset() click to toggle source
#

grab_resolution_from_the_dataset

#
# File lib/multimedia_paradise/video/resolution.rb, line 90
def grab_resolution_from_the_dataset
  _ = dataset?.first.strip
  use_this_regex = / (\d+x\d+) / # See: http://rubular.com/r/qvuyHxVDdg
  _ =~ use_this_regex
  set_resolution $1.to_s.dup
end
guess_width_and_height(i = @resolution) click to toggle source
#

guess_width_and_height

#
# File lib/multimedia_paradise/video/resolution.rb, line 108
def guess_width_and_height(i = @resolution)
  if i.include? 'x'
    splitted = i.split('x')
    @width  = splitted.first
    @height = splitted.last
  end
end
height?() click to toggle source
#

height?

#
# File lib/multimedia_paradise/video/resolution.rb, line 126
def height?
  @height
end
input?() click to toggle source
#

input?

#
# File lib/multimedia_paradise/video/resolution.rb, line 53
def input?
  @input
end
obtain_dataset_via_ffmpeg( input = input? ) click to toggle source
#

obtain_dataset_via_ffmpeg

#
# File lib/multimedia_paradise/video/resolution.rb, line 60
def obtain_dataset_via_ffmpeg(
    input = input?
  )
  if input.nil?
    e 'Please supply a valid argument, a video or audio file.'
  else
    _ = 'ffmpeg -i '+input+' 2>&1'
    @dataset = `#{_}`
  end
end
report()
Alias for: report_resolution
report_resolution() click to toggle source
#

report_resolution

#
# File lib/multimedia_paradise/video/resolution.rb, line 140
def report_resolution
  e 'The resolution of '+sfile(input?)+' is: '
  e '  '+simp(res?)
end
Also aliased as: report
res?()
Alias for: resolution?
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method MultimediaParadise::Base#reset
# File lib/multimedia_paradise/video/resolution.rb, line 36
def reset
  super()
  @dataset = nil
end
resolution?() click to toggle source
#

resolution?

#
# File lib/multimedia_paradise/video/resolution.rb, line 133
def resolution?
  @resolution
end
Also aliased as: res?
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/video/resolution.rb, line 148
def run
  obtain_dataset_via_ffmpeg
  filter_dataset
  grab_resolution_from_the_dataset
end
set_input(i = '') click to toggle source
#

set_input

#
# File lib/multimedia_paradise/video/resolution.rb, line 44
def set_input(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup if i
  @input = i
end
set_resolution(i = nil) click to toggle source
#

set_resolution

#
# File lib/multimedia_paradise/video/resolution.rb, line 100
def set_resolution(i = nil)
  @resolution = i
  guess_width_and_height if @resolution
end
width?() click to toggle source
#

width?

#
# File lib/multimedia_paradise/video/resolution.rb, line 119
def width?
  @width
end