class Qwik::RealProducer

Attributes

real_server_content_dir[R]

Public Class Methods

new(config, site) click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 176
def initialize(config, site)
  @config = config
  @site = site
  @cmd = @config.real_producer
  @audience = '768k'
  @real_server_content_dir = @config.real_server_content
  @o = ($VERBOSE) ? $stdout : StringIO.new
end

Public Instance Methods

encode_all() click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 195
def encode_all
  path = @site.attach.path
  path.each_entry {|file|
    base = file.basename.to_s
    next unless /\A(.+)\.avi\z/i =~ base || /\A(.+)\.mp4\z/i =~ base
    output_base = $1+'.rm'
    output = path+output_base
    if output.exist?
      puts "already exist: #{output.to_s}"
      next
    end
    encode_file(path+file)
  }
end
encode_file(input, output, msg=nil) click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 210
def encode_file(input, output, msg=nil)
  m = msg ? msg : @o
  inf  =  input.to_win_dir
  outf = output.to_win_dir
  m.puts "start encode #{inf}"
  open("|#{@cmd} -i #{inf} -o #{outf} -ad #{@audience}"){|f|
    while line = f.gets
      m.print line.normalize_eol
    end
  }
  m.puts
end
output_file(input) click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 186
def output_file(input)
  path = @real_server_content_dir.path+@site.sitename
  base = input.basename.to_s
  base = base.sub(%r!\A(.+)\.(\w+)!){|a| $1 }
  outbase = "#{base}.rm"
  output = path+outbase
  output
end
show_audience_list() click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 235
def show_audience_list
  @o.puts(open("|#{@cmd} -pa"){|f| f.read })
end
show_help() click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 227
def show_help
  @o.puts(open("|#{@cmd} -h"){|f| f.read })
end
show_more_help() click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 231
def show_more_help
  @o.puts(open("|#{@cmd} -m"){|f| f.read })
end
show_version() click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 223
def show_version
  @o.puts(open("|#{@cmd} -pa"){|f| f.read })
end