Class: Pruview::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/pruview/video.rb

Constant Summary collapse

FFYML =

Configurations

File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'ffyml'))
FFMPEG =
'ffmpeg'
FLVTOOL =
'flvtool2'
PAD_COLOR =
"000000"
AUDIO_BITRATE =

kbps

128
AUDIO_SAMPLING =
44100
EXT =
['.avi', '.flv', '.mov', '.mpg', '.mp4']

Instance Method Summary collapse

Constructor Details

#initialize(source, target_dir, bitrate_mult = 1) ⇒ Video

this class assumes you have ‘ffmpeg’ and ‘flvtool2’ installed and in your path



16
17
18
19
20
21
22
23
# File 'lib/pruview/video.rb', line 16

def initialize(source, target_dir, bitrate_mult = 1)
  raise Pruview::Exceptions::InvalidError, "Invalid source file:: #{source.to_s}" if !File.file?(source)
  raise Pruview::Exceptions::InvalidError, "Invalid target directory: #{target_dir.to_s}" if !File.directory?(target_dir)
  raise Pruview::Exceptions::InvalidError, "Video not supported - file extension: " + file_extension(source) if !format_supported?(source)
  @source = source
  @target_dir = target_dir
  @bitrate_multiplier = bitrate_mult
end

Instance Method Details

#infoObject



37
38
39
40
# File 'lib/pruview/video.rb', line 37

def info
  yml_info_path = Tempfile.new("#{File.basename(@source)}.yml").path
  self.get_info(yml_info_path)
end

#to_flv(name, width, height, scale_static = false) ⇒ Object



25
26
27
28
29
# File 'lib/pruview/video.rb', line 25

def to_flv(name, width, height, scale_static = false)
  target = to_base(name, width, height, '.flv', scale_static)
  run("#{FLVTOOL} -U #{target}", "Unable to add meta-data for #{target}.")
  return target
end

#to_jpg(name) ⇒ Object



42
43
44
# File 'lib/pruview/video.rb', line 42

def to_jpg(name)
  VideoImage.to_jpg(@source, @target_dir, name)
end

#to_mov(name, width, height, scale_static = false) ⇒ Object



31
32
33
34
35
# File 'lib/pruview/video.rb', line 31

def to_mov(name, width, height, scale_static = false)
  target = to_base(name, width, height, '.mov', scale_static)
  # TODO: run qt-faststart
  return target
end