Class: MkvToolNix::Modules::MkvMerge

Inherits:
Object
  • Object
show all
Includes:
MkvModule
Defined in:
lib/mkvtoolnix/modules/mkvmerge.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MkvModule

#call_cmd

Constructor Details

#initialize(bin_path) ⇒ MkvMerge

Returns a new instance of MkvMerge.



11
12
13
14
15
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 11

def initialize(bin_path)
  @bin_path = "#{bin_path}mkvmerge"
  @default_language = 'und'
  @disable_language_ietf = false
end

Instance Attribute Details

#default_languageObject

Returns the value of attribute default_language.



9
10
11
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 9

def default_language
  @default_language
end

#disable_language_ietfObject

Returns the value of attribute disable_language_ietf.



9
10
11
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 9

def disable_language_ietf
  @disable_language_ietf
end

Instance Method Details

#build_attachment(file) ⇒ Object



60
61
62
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 60

def build_attachment(file)
  Types::Merge::Attachment.new(file)
end

#build_chapterObject



64
65
66
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 64

def build_chapter
  Types::Merge::Chapter.new
end

#build_input_file(file) ⇒ Object



76
77
78
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 76

def build_input_file(file)
  Types::Merge::InputFile.new(file)
end

#build_output_controlObject



72
73
74
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 72

def build_output_control
  Types::Merge::OutputControl.new
end

#build_segment_infoObject



56
57
58
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 56

def build_segment_info
  Types::Merge::SegmentInfo.new
end

#build_tags(file) ⇒ Object



68
69
70
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 68

def build_tags(file)
  Types::Merge::Tags.new(file)
end

#info(file) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 46

def info(file)
  cmd = [@bin_path, '-J']
  cmd << file

  result = call_cmd(cmd)

  json = JSON.parse(result.stdout)
  Types::Info::MkvContainer.create(json)
end

#merge(output_file, *input_files, attachments: nil, chapter_options: nil, tag_options: nil, output_control: nil, segment_info: nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 25

def merge(output_file, *input_files, attachments: nil, chapter_options: nil, tag_options: nil,
          output_control: nil, segment_info: nil)
  raise Errors::MkvToolNixError, 'No Input File(s) given.' if input_files.nil?

  cmd = ['mkvmerge']

  attachments&.each { |attachment| attachment.add_to_cmd(cmd) }
  chapter_options&.add_to_cmd(cmd)
  segment_info&.add_to_cmd(cmd)
  tag_options&.add_to_cmd(cmd)
  output_control&.add_to_cmd(cmd)

  cmd << '-o' << output_file

  input_files.each { |input| input.add_to_cmd(cmd) }

  a = cmd.join(' ')

  call_cmd(cmd)
end

#versionObject



17
18
19
20
21
22
23
# File 'lib/mkvtoolnix/modules/mkvmerge.rb', line 17

def version
  cmd = [@bin_path, '-V']

  result = call_cmd(cmd)

  result.stdout.strip
end