class Mkv2m4v::File

Constants

HIGHLIGHT_COLOR

Attributes

audio_tracks[R]
filtered_audio_tracks[R]
filtered_text_tracks[R]
filtered_video_tracks[R]
ideal_audio_track[R]
ideal_text_track[R]
ideal_video_track[R]
info[R]
text_tracks[R]
video_tracks[R]

Public Class Methods

each(filenames, options = {}) { |new(filename, options)| ... } click to toggle source
# File lib/mkv2m4v/file.rb, line 43
def self.each(filenames, options = {})
  filenames.each do |filename|
    if ::File.exists?(filename)
      yield new(filename, options)
    else
      $stderr.puts "#{filename} does not exist."
    end
  end
end
new(filename, options = {}) click to toggle source
# File lib/mkv2m4v/file.rb, line 19
def initialize(filename, options = {})
  @info = Mediainfo.new(filename)
  @options = options
  @languages = @options[:languages]
  init_tracks
end

Public Instance Methods

format() click to toggle source
# File lib/mkv2m4v/file.rb, line 26
def format
  info.general.format
end
print_info() click to toggle source
transcode() click to toggle source
# File lib/mkv2m4v/file.rb, line 36
def transcode
  process do
    print_ideal_tracks
    Transcoder.new(self, @options).run
  end
end

Private Instance Methods

init_tracks() click to toggle source
# File lib/mkv2m4v/file.rb, line 96
def init_tracks
  @video_tracks = tracks_by_type(:video).rank
  @audio_tracks = tracks_by_type(:audio).rank
  @text_tracks  = tracks_by_type(:text).rank

  @filtered_video_tracks = video_tracks.filter
  @filtered_audio_tracks = audio_tracks.filter
  @filtered_text_tracks  = text_tracks.filter

  @ideal_video_track = filtered_video_tracks.first
  @ideal_audio_track = filtered_audio_tracks.first
  @ideal_text_track  = filtered_text_tracks.first
end
postamble() click to toggle source
# File lib/mkv2m4v/file.rb, line 67
def postamble
  puts
end
preamble() click to toggle source
# File lib/mkv2m4v/file.rb, line 61
def preamble
  print "#{format}: #{name}".black.on_yellow
  langs = @languages.empty? ? "all languages" : @languages.join(", ")
  puts " (matching #{langs})".yellow.on_black
end
print_all_tracks() click to toggle source
print_filtered_tracks() click to toggle source
print_ideal_tracks() click to toggle source
process() { || ... } click to toggle source
# File lib/mkv2m4v/file.rb, line 55
def process
  preamble
  yield
  postamble
end
tracks_by_type(type) click to toggle source
# File lib/mkv2m4v/file.rb, line 110
def tracks_by_type(type)
  info_tracks = info.send(type)
  tracks = info_tracks.count.times.map do |i|
    Mkv2m4v.const_get("#{type.to_s.capitalize}Track").new(info_tracks[i])
  end
  Mkv2m4v.const_get("#{type.to_s.capitalize}Ranker").new(tracks, @options)
end