Class: MkvToolNix::Modules::MkvExtract

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MkvModule

#call_cmd

Constructor Details

#initialize(bin_path) ⇒ MkvExtract

Returns a new instance of MkvExtract.



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

def initialize(bin_path)
  @bin_path = "#{bin_path}mkvextract"
  @abort_at_warning = false
end

Instance Attribute Details

#abort_at_warningObject

Returns the value of attribute abort_at_warning.



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

def abort_at_warning
  @abort_at_warning
end

Instance Method Details

#extract_attachments(file, attachments, full_parse_mode: false) ⇒ Object

extracts the selected attachments

Parameters:

  • file (String)

    path to the mkv file

  • attachments (Array)

    a list of Attachments, Strings or Hashes or a mix of them.

  • full_parse_mode (Boolean) (defaults to: false)

    sets full parse mod



52
53
54
55
56
57
58
59
# File 'lib/mkvtoolnix/modules/mkvextract.rb', line 52

def extract_attachments(file, attachments, full_parse_mode: false)
  cmd = [@bin_path, file, 'attachments']
  add_default_options(cmd, full_parse_mode)

  add_id_file_list(cmd, attachments)

  call_cmd(cmd)
end

#extract_chapters(file, out_file, simple: false, simple_language: nil, full_parse_mode: false) ⇒ Object

extracts the chapter xml file

Parameters:

  • file (String)

    path to the mkv file

  • out_file (String)

    path to the file to write the chapter xml file to

  • full_parse_mode (Boolean) (defaults to: false)

    sets full parse mod



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/mkvtoolnix/modules/mkvextract.rb', line 66

def extract_chapters(file, out_file, simple: false, simple_language: nil, full_parse_mode: false)
  cmd = [@bin_path, file, 'chapters']
  add_default_options(cmd, full_parse_mode)

  cmd << '--simple' if simple
  cmd << '--simple-language' << simple_language unless simple_language.nil?

  cmd << out_file

  call_cmd(cmd)
end

#extract_cue_sheet(file, out_file, full_parse_mode: false) ⇒ Object

extracts the cue sheet

Parameters:

  • file (String)

    path to the mkv file

  • out_file (String)

    path to the file to write cue sheet file to

  • full_parse_mode (Boolean) (defaults to: false)

    sets full parse mod



97
98
99
100
101
102
103
104
# File 'lib/mkvtoolnix/modules/mkvextract.rb', line 97

def extract_cue_sheet(file, out_file, full_parse_mode: false)
  cmd = [@bin_path, file, 'cuesheet']
  add_default_options(cmd, full_parse_mode)

  cmd << out_file

  call_cmd(cmd)
end

#extract_cues(file, tracks, full_parse_mode: false) ⇒ Object

extracts the cues of the selected tracks

Parameters:

  • file (String)

    path to the mkv file

  • tracks (Array)

    a list of Tracks, Strings or Hashes or a mix of them.

  • full_parse_mode (Boolean) (defaults to: false)

    sets full parse mod



125
126
127
128
129
130
131
132
# File 'lib/mkvtoolnix/modules/mkvextract.rb', line 125

def extract_cues(file, tracks, full_parse_mode: false)
  cmd = [@bin_path, file, 'cues']
  add_default_options(cmd, full_parse_mode)

  add_id_file_list(cmd, tracks)

  call_cmd(cmd)
end

#extract_tags(file, out_file, full_parse_mode: false) ⇒ Object

extracts the tags xml file

Parameters:

  • file (String)

    path to the mkv file

  • out_file (String)

    path to the file to write the tags xml file to

  • full_parse_mode (Boolean) (defaults to: false)

    sets full parse mod



83
84
85
86
87
88
89
90
# File 'lib/mkvtoolnix/modules/mkvextract.rb', line 83

def extract_tags(file, out_file, full_parse_mode: false)
  cmd = [@bin_path, file, 'tags']
  add_default_options(cmd, full_parse_mode)

  cmd << out_file

  call_cmd(cmd)
end

#extract_timestamps(file, tracks, full_parse_mode: false) ⇒ Object

extracts the timestamps of the selected tracks

Parameters:

  • file (String)

    path to the mkv file

  • tracks (Array)

    a list of Tracks, Strings or Hashes or a mix of them.

  • full_parse_mode (Boolean) (defaults to: false)

    sets full parse mod



111
112
113
114
115
116
117
118
# File 'lib/mkvtoolnix/modules/mkvextract.rb', line 111

def extract_timestamps(file, tracks, full_parse_mode: false)
  cmd = [@bin_path, file, 'timestamps_v2']
  add_default_options(cmd, full_parse_mode)

  add_id_file_list(cmd, tracks)

  call_cmd(cmd)
end

#extract_tracks(file, tracks, extract_cuesheet: false, raw: false, full_raw: false, full_parse_mode: false) ⇒ Object

extracts the selected tracks

Parameters:

  • file (String)

    path to the mkv file

  • tracks (Array)

    a list of Tracks, Strings or Hashes or a mix of them.

  • extract_cuesheet (Boolean) (defaults to: false)

    extracts the cuesheet to [filename].cue

  • raw (Boolean) (defaults to: false)

    if true, extracts the raw file, does not contain the CodecPrivate element

  • full_raw (Boolean) (defaults to: false)

    if true, extracts the raw file, does contain the CodecPrivate element

  • full_parse_mode (Boolean) (defaults to: false)

    sets full parse mod



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mkvtoolnix/modules/mkvextract.rb', line 35

def extract_tracks(file, tracks, extract_cuesheet: false, raw: false, full_raw: false, full_parse_mode: false)
  cmd = [@bin_path, file, 'tracks']
  add_default_options(cmd, full_parse_mode)
  cmd << '--cuesheet' if extract_cuesheet
  cmd << '--raw' if raw
  cmd << '--fullraw' if full_raw

  add_id_file_list(cmd, tracks)

  call_cmd(cmd)
end

#versionObject

returns the mkvextract version

return [String] the version string



19
20
21
22
23
24
25
# File 'lib/mkvtoolnix/modules/mkvextract.rb', line 19

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

  result = call_cmd(cmd)

  result.stdout.strip
end