dvdvrconv 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dvdvrconv.gemspec +26 -0
- data/exe/dvdvrconv +5 -0
- data/lib/dvdvrconv.rb +8 -0
- data/lib/dvdvrconv/command.rb +134 -0
- data/lib/dvdvrconv/dvdvr.rb +336 -0
- data/lib/dvdvrconv/options.rb +39 -0
- data/lib/dvdvrconv/version.rb +3 -0
- data/sample_default_dvdvrconv.yaml +49 -0
- data/sample_my.yaml +46 -0
- data/test-unit.yml +11 -0
- data/win/cygiconv-2.dll +0 -0
- data/win/cygwin1.dll +0 -0
- data/win/dvd-vr.exe +0 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e2d10d9271d41efbcd111cafd6fd2857c08fa46214eb392bb58c93146dc551e
|
4
|
+
data.tar.gz: b42749f99ecf8fb55af4c1b9a7efc05cb0c79d503a09105eb5a1395cb0e444ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de0350ed29feffd1af1b96ab3af41306694f27df93b1bc3ca155d6ca346f33f0b715273b2573be20c32f7274af3729947708ef2478744db1527aee558851198d
|
7
|
+
data.tar.gz: f9c7100785925fb1b053a0d0bc29520561519fb33c02f8ad0594889a8fa1c4ee4c114d53252bfba60ceb1a6e5f0c4fef2a98b605abfe969244cfcb124f843099
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 icm7216
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Dvdvrconv
|
2
|
+
|
3
|
+
|
4
|
+
Dvdvrconv extracts the `vob` file from the `vro` file on the dvd-vr format disc.
|
5
|
+
Dvdvrconv is also a wrapper for [pixelb/dvd-vr](https://github.com/pixelb/dvd-vr/).
|
6
|
+
|
7
|
+
For Windows users, I attached `dvd-vr.exe` for cygwin environment.
|
8
|
+
|
9
|
+
## dependent libraries
|
10
|
+
|
11
|
+
* [pixelb/dvd-vr](https://github.com/pixelb/dvd-vr/)
|
12
|
+
* FFmpeg
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'dvdvrconv'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
```ruby
|
24
|
+
$ bundle install
|
25
|
+
```
|
26
|
+
Or install it yourself as:
|
27
|
+
```ruby
|
28
|
+
$ gem install dvdvrconv
|
29
|
+
```
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
TODO:
|
35
|
+
* Write usage instructions here
|
36
|
+
* Add command options
|
37
|
+
|
38
|
+
## Development
|
39
|
+
|
40
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
41
|
+
|
42
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
49
|
+
|
50
|
+
pixelb/dvd-vr is licensed under the GNU General Public License v2.0
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dvdvrconv"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/dvdvrconv.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative "lib/dvdvrconv/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "dvdvrconv"
|
5
|
+
spec.version = Dvdvrconv::VERSION
|
6
|
+
spec.authors = ["icm7216"]
|
7
|
+
spec.email = ["icm7216d@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{DVD-VR utility}
|
10
|
+
spec.description = %q{This tool converts "vor" file on DVD-VR format disc to "vob" files.}
|
11
|
+
spec.homepage = "https://github.com/icm7216/dvdvrconv"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "test-unit"
|
25
|
+
spec.add_development_dependency "test-unit-rr"
|
26
|
+
end
|
data/exe/dvdvrconv
ADDED
data/lib/dvdvrconv.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
module Dvdvrconv
|
2
|
+
class Command
|
3
|
+
def self.run(argv)
|
4
|
+
new(argv).execute
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(argv)
|
8
|
+
@argv = argv
|
9
|
+
@options = {}
|
10
|
+
|
11
|
+
config_file = Dvdvrconv::DEFAULT_CONFIG_FILE
|
12
|
+
if File.exist?(config_file)
|
13
|
+
load_config(config_file)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# For now, this test code returns dummy dvd-vr information.
|
18
|
+
def execute
|
19
|
+
options = Dvdvrconv::Options.parse(@argv)
|
20
|
+
dvd = Dvdvrconv::Dvdvr.new
|
21
|
+
|
22
|
+
# Set the path specified in the yaml file.
|
23
|
+
dvd.vrdisc.opts_ifo = @options[:vr_mangr_ifo] if @options[:vr_mangr_ifo]
|
24
|
+
dvd.vrdisc.opts_vro = @options[:vr_movie_vro] if @options[:vr_movie_vro]
|
25
|
+
dvd.vrdisc.cmd = @options[:dvd_vr_cmd] if @options[:dvd_vr_cmd]
|
26
|
+
|
27
|
+
# dvd.vrdisc.opts_ifo = "test/DVD_RTAV/VR_MANGR.IFO"
|
28
|
+
# dvd.vrdisc.opts_vro = "test/DVD_RTAV/VR_MOVIE.VRO"
|
29
|
+
|
30
|
+
if options[:opt][:config_file]
|
31
|
+
puts "Use config file\n => #{options[:opt][:config_file]}"
|
32
|
+
opt_config_file = options[:opt][:config_file]
|
33
|
+
load_config(opt_config_file) if File.exist?(opt_config_file)
|
34
|
+
dvd.vrdisc.opts_ifo = @options[:vr_mangr_ifo] if @options[:vr_mangr_ifo]
|
35
|
+
dvd.vrdisc.opts_vro = @options[:vr_movie_vro] if @options[:vr_movie_vro]
|
36
|
+
dvd.vrdisc.cmd = @options[:dvd_vr_cmd] if @options[:dvd_vr_cmd]
|
37
|
+
end
|
38
|
+
|
39
|
+
# View the path of each files
|
40
|
+
puts "== Use these paths =="
|
41
|
+
puts " => VR_MANGR.IFO: #{dvd.vrdisc.opts_ifo}"
|
42
|
+
puts " => VR_MOVIE.VRO #{dvd.vrdisc.opts_vro}"
|
43
|
+
puts " => dvd-vr.exe: #{dvd.vrdisc.cmd}"
|
44
|
+
|
45
|
+
dvd.read_info
|
46
|
+
|
47
|
+
if options[:opt][:info]
|
48
|
+
dvd.view_info
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
|
52
|
+
# Extract vob files
|
53
|
+
dvd.adjust_title
|
54
|
+
dvd.vro2vob
|
55
|
+
|
56
|
+
# Change the file name to the title name
|
57
|
+
dvd.change_to_title_name
|
58
|
+
dvd.rename_vob
|
59
|
+
|
60
|
+
# Concatenate Split titles
|
61
|
+
concat_list = dvd.make_concat_list
|
62
|
+
dvd.concat_titles(concat_list)
|
63
|
+
|
64
|
+
# customize title of vob files
|
65
|
+
case @options[:use_customize_title]
|
66
|
+
when 1
|
67
|
+
puts "Specify individual file names."
|
68
|
+
|
69
|
+
if @options[:base_dst_name].class == Array
|
70
|
+
base_dst_name = @options[:base_dst_name]
|
71
|
+
else
|
72
|
+
puts "ERROR: base_dst_name should be an Array. \n ( => #{@options[:base_dst_name]})"
|
73
|
+
exit
|
74
|
+
end
|
75
|
+
|
76
|
+
number_list = []
|
77
|
+
when 2
|
78
|
+
puts "Add sequence number to the file name."
|
79
|
+
|
80
|
+
if @options[:base_dst_name].class == String
|
81
|
+
base_dst_name = @options[:base_dst_name]
|
82
|
+
else
|
83
|
+
puts "ERROR: base_dst_name should be String. \n ( => #{@options[:base_dst_name]})"
|
84
|
+
exit
|
85
|
+
end
|
86
|
+
|
87
|
+
number_list = []
|
88
|
+
when 3
|
89
|
+
puts "Specify sequence numbers individually."
|
90
|
+
|
91
|
+
if @options[:base_dst_name].class == String
|
92
|
+
base_dst_name = @options[:base_dst_name]
|
93
|
+
else
|
94
|
+
puts "ERROR: base_dst_name should be String. \n ( => #{@options[:base_dst_name]})"
|
95
|
+
exit
|
96
|
+
end
|
97
|
+
|
98
|
+
if @options[:number_list].class == Array
|
99
|
+
number_list = @options[:number_list]
|
100
|
+
else
|
101
|
+
puts "ERROR: number_list should be an Array."
|
102
|
+
exit
|
103
|
+
end
|
104
|
+
else
|
105
|
+
puts "No customize file names"
|
106
|
+
base_dst_name = dvd.vrdisc.title.uniq.map { |file| file[0].gsub(/\s/, "_") }
|
107
|
+
number_list = []
|
108
|
+
end
|
109
|
+
|
110
|
+
dvd.customize_title(base_dst_name, number_list)
|
111
|
+
dvd.rename_vob
|
112
|
+
|
113
|
+
# convert vob to mp4
|
114
|
+
dvd.vob2mp4
|
115
|
+
end
|
116
|
+
|
117
|
+
# load yaml file and store in @options.
|
118
|
+
def load_config(file)
|
119
|
+
config = YAML.load(File.read(file))
|
120
|
+
|
121
|
+
%w(vr_mangr_ifo vr_movie_vro dvd_vr_cmd).each do |file|
|
122
|
+
if File.exist?(config[file])
|
123
|
+
@options[file.to_sym] = config[file]
|
124
|
+
else
|
125
|
+
puts "File read error. No such file: #{config[file]}"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
@options[:use_customize_title] = config["use_customize_title"] || "no"
|
130
|
+
@options[:base_dst_name] = config["base_dst_name"] || []
|
131
|
+
@options[:number_list] = config["number_list"] || []
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,336 @@
|
|
1
|
+
module Dvdvrconv
|
2
|
+
|
3
|
+
# DVD-VR disc status
|
4
|
+
Vrdisc = Struct.new(
|
5
|
+
:header, # @param [String]
|
6
|
+
:num, # @param [Array<String>]
|
7
|
+
:title, # @param [Array<String>]
|
8
|
+
:date, # @param [Array<String>]
|
9
|
+
:size, # @param [Array<String>]
|
10
|
+
:opts_ifo, # @param [String]
|
11
|
+
:opts_vro, # @param [String]
|
12
|
+
:cmd, # @param [String]
|
13
|
+
:output_title, # @param [Array<String>]
|
14
|
+
:duplicate_name, # @param [Array<String>]
|
15
|
+
:vob_titles, # @param [Array<String>]
|
16
|
+
)
|
17
|
+
|
18
|
+
BASE_NAME = "DVD"
|
19
|
+
DEFAULT_CONFIG_FILE = "default_dvdvrconv.yaml"
|
20
|
+
|
21
|
+
# Default DVD drive is "d".
|
22
|
+
# If you want to use a different drive, you need to set up a "default_dvdvrconv.yaml" file.
|
23
|
+
WIN_DRV_IFO = "/cygdrive/D/DVD_RTAV/VR_MANGR.IFO"
|
24
|
+
WIN_DRV_VRO = "/cygdrive/D/DVD_RTAV/VR_MOVIE.VRO"
|
25
|
+
WIN_DRV_CMD = "win/dvd-vr.exe"
|
26
|
+
DRV_IFO = "/mnt/d/DVD_RTAV/VR_MANGR.IFO"
|
27
|
+
DRV_VRO = "/mnt/d/DVD_RTAV/VR_MOVIE.VRO"
|
28
|
+
DRV_CMD = "dvd-vr"
|
29
|
+
|
30
|
+
class Dvdvr
|
31
|
+
attr_accessor :vrdisc
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
@vrdisc = Vrdisc.new(nil)
|
35
|
+
|
36
|
+
if RUBY_PLATFORM =~ /mswin(?!ce)|mingw|cygwin/
|
37
|
+
@vrdisc.opts_ifo = Dvdvrconv::WIN_DRV_IFO
|
38
|
+
@vrdisc.opts_vro = Dvdvrconv::WIN_DRV_VRO
|
39
|
+
@vrdisc.cmd = Dvdvrconv::WIN_DRV_CMD
|
40
|
+
else
|
41
|
+
@vrdisc.opts_ifo = Dvdvrconv::DRV_IFO
|
42
|
+
@vrdisc.opts_vro = Dvdvrconv::DRV_VRO
|
43
|
+
@vrdisc.cmd = Dvdvrconv::DRV_CMD
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Read VRO file from dvd-ram disc in dvd-vr format, and output vob files.
|
48
|
+
def str_dvdvr_cmd
|
49
|
+
%Q[#{@vrdisc.cmd} --name=#{Dvdvrconv::BASE_NAME} #{@vrdisc.opts_ifo} #{@vrdisc.opts_vro}]
|
50
|
+
end
|
51
|
+
|
52
|
+
# Make a concatenation command string for FFmpeg.
|
53
|
+
def str_concat_cmd(file_name, base_name)
|
54
|
+
%Q[ffmpeg -f concat -safe 0 -i #{file_name} -c copy #{base_name}.vob]
|
55
|
+
end
|
56
|
+
|
57
|
+
# File convert command, vob to mp4 for FFmpeg.
|
58
|
+
# * Change the aspect ratio to 16:9.
|
59
|
+
# * Delete a closed caption.
|
60
|
+
def str_convert_cmd(file_name)
|
61
|
+
%Q[ffmpeg -i #{file_name}.vob -filter:v "crop=704:474:0:0" -vcodec libx264 -b:v 500k -aspect 16:9 -acodec copy -bsf:v "filter_units=remove_types=6" #{file_name}.mp4]
|
62
|
+
end
|
63
|
+
|
64
|
+
# Read video information from dvd-ram discs in dvd-vr format.
|
65
|
+
#
|
66
|
+
# required values:
|
67
|
+
# @vrdisc.cmd, @vrdisc.opts_ifo
|
68
|
+
#
|
69
|
+
# Get values of the video information:
|
70
|
+
# => @vrdisc.header
|
71
|
+
# => @vrdisc.num
|
72
|
+
# => @vrdisc.title
|
73
|
+
# => @vrdisc.date
|
74
|
+
# => @vrdisc.size
|
75
|
+
#
|
76
|
+
def read_info
|
77
|
+
out, err, status = Open3.capture3(@vrdisc.cmd, @vrdisc.opts_ifo)
|
78
|
+
@vrdisc.header = out.scan(/^(.*?)Number/m)
|
79
|
+
|
80
|
+
# Sets the captured information to @vrdisc.
|
81
|
+
%w(num title date size).each do |item|
|
82
|
+
str = format("%-5s", item) + ":"
|
83
|
+
@vrdisc[item] = out.scan(/#{str}\s(.*?)$/)
|
84
|
+
end
|
85
|
+
|
86
|
+
out
|
87
|
+
end
|
88
|
+
|
89
|
+
# View video information from dvd-ram discs in dvd-vr format.
|
90
|
+
#
|
91
|
+
# required values:
|
92
|
+
# @vrdisc.header, @vrdisc.num, @vrdisc.title,
|
93
|
+
# @vrdisc.date, @vrdisc.size
|
94
|
+
#
|
95
|
+
def view_info
|
96
|
+
puts "----- view dvd-vr info -----"
|
97
|
+
puts @vrdisc.header
|
98
|
+
[@vrdisc.num, @vrdisc.title, @vrdisc.date, @vrdisc.size].transpose.each do |x|
|
99
|
+
%w(num title date size).each_with_index do |item, idx|
|
100
|
+
line = format("%-5s", item) + ": #{x.flatten[idx].to_s}\n"
|
101
|
+
puts line
|
102
|
+
end
|
103
|
+
puts "-"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Add sequence number to the duplicate title name.
|
108
|
+
# Replace white space in the title with underscore.
|
109
|
+
#
|
110
|
+
# required value:
|
111
|
+
# @vrdisc.title
|
112
|
+
#
|
113
|
+
# Output values:
|
114
|
+
# => @vrdisc.duplicate_name
|
115
|
+
# => @vrdisc.output_title
|
116
|
+
#
|
117
|
+
def adjust_title
|
118
|
+
output_title = []
|
119
|
+
duplicate_names = []
|
120
|
+
dup_counter = 0
|
121
|
+
|
122
|
+
# Extract duplicate names from title.
|
123
|
+
dup = @vrdisc.title.select { |x| @vrdisc.title.count(x) > 1 }
|
124
|
+
|
125
|
+
@vrdisc.title.each_index do |idx|
|
126
|
+
# Replace white space in the title with underscore.
|
127
|
+
new_name = @vrdisc.title[idx][0].gsub(/\s/, "_")
|
128
|
+
|
129
|
+
# Add sequential numbers to duplicate name.
|
130
|
+
if dup.include?(@vrdisc.title[idx])
|
131
|
+
dup_counter += 1
|
132
|
+
output_title << format("%s_%02d", new_name, dup_counter)
|
133
|
+
duplicate_names << new_name
|
134
|
+
else
|
135
|
+
output_title << format("%s", new_name)
|
136
|
+
end
|
137
|
+
dup_counter = 0 if dup_counter == @vrdisc.title.count(@vrdisc.title[idx])
|
138
|
+
end
|
139
|
+
|
140
|
+
@vrdisc.duplicate_name = duplicate_names.select do |x|
|
141
|
+
duplicate_names.count(x) > 1
|
142
|
+
end.uniq
|
143
|
+
|
144
|
+
@vrdisc.output_title = output_title
|
145
|
+
end
|
146
|
+
|
147
|
+
# Read VRO file from dvd-ram disc in dvd-vr format, and output vob files.
|
148
|
+
def vro2vob
|
149
|
+
cmd = str_dvdvr_cmd
|
150
|
+
puts "----- convert file VRO to VOB -----"
|
151
|
+
puts "> cmd:\n #{cmd}"
|
152
|
+
system(cmd)
|
153
|
+
puts ""
|
154
|
+
end
|
155
|
+
|
156
|
+
# Change the file name to the title name
|
157
|
+
#
|
158
|
+
# required value:
|
159
|
+
# @vrdisc.title
|
160
|
+
#
|
161
|
+
# Output values:
|
162
|
+
# => @vrdisc.vob_titles
|
163
|
+
#
|
164
|
+
def change_to_title_name
|
165
|
+
vob_titles = []
|
166
|
+
|
167
|
+
@vrdisc.title.size.times do |x|
|
168
|
+
src = format("%s#%03d", Dvdvrconv::BASE_NAME, x + 1) + ".vob"
|
169
|
+
dst = @vrdisc.output_title[x] + ".vob"
|
170
|
+
vob_titles << [src, dst]
|
171
|
+
end
|
172
|
+
|
173
|
+
@vrdisc.vob_titles = vob_titles
|
174
|
+
end
|
175
|
+
|
176
|
+
# customize the title of vob files.
|
177
|
+
#
|
178
|
+
# If specify individual file names. Write "base_dst_name" as an Array.
|
179
|
+
#
|
180
|
+
# base_dst_name = ["name_one", "name_two"]
|
181
|
+
# number_list = []
|
182
|
+
# => ["name_one", "name_two"]
|
183
|
+
#
|
184
|
+
# If add a sequence number to the file name. Write "base_dst_name" as String.
|
185
|
+
#
|
186
|
+
# base_dst_name = "output_name_"
|
187
|
+
# number_list = []
|
188
|
+
# => ["output_name_01", "output_name_02", ...]
|
189
|
+
#
|
190
|
+
# If specify sequence numbers individually.
|
191
|
+
# Write "base_dst_name" as String and Write "number_list" as an Array.
|
192
|
+
#
|
193
|
+
# base_dst_name = "output_name_"
|
194
|
+
# number_list = [12, 13, 14, 15]
|
195
|
+
# => ["output_name_12", "output_name_13", "output_name_14", "output_name_15"]
|
196
|
+
#
|
197
|
+
# required Argument, value:
|
198
|
+
# base_dst_name, number_list,
|
199
|
+
# @vrdisc.title
|
200
|
+
#
|
201
|
+
# Output values:
|
202
|
+
# => @vrdisc.vob_titles
|
203
|
+
#
|
204
|
+
def customize_title(base_dst_name, number_list = [])
|
205
|
+
vob_titles = []
|
206
|
+
|
207
|
+
base_dst_name.size.times do |x|
|
208
|
+
break if x > @vrdisc.title.uniq.size - 1
|
209
|
+
src = @vrdisc.title.uniq[x][0].gsub(/\s/, "_") + ".vob"
|
210
|
+
|
211
|
+
case base_dst_name
|
212
|
+
when Array
|
213
|
+
dst_name = base_dst_name[x]
|
214
|
+
when String
|
215
|
+
if number_list.size.zero?
|
216
|
+
dst_name = base_dst_name + format("_%02d", x + 1)
|
217
|
+
else
|
218
|
+
dst_name = base_dst_name + format("_%02d", number_list[x])
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
dst = dst_name + ".vob"
|
223
|
+
vob_titles << [src, dst]
|
224
|
+
end
|
225
|
+
|
226
|
+
@vrdisc.vob_titles = vob_titles
|
227
|
+
end
|
228
|
+
|
229
|
+
# Rename vob file to a customized title name.
|
230
|
+
#
|
231
|
+
# @param [String] file_titles is Array. Includes pair of source and destination filename.
|
232
|
+
# * [[src, dst], [src, dst], [src, dst], ....]
|
233
|
+
#
|
234
|
+
# required value:
|
235
|
+
# @vrdisc.vob_titles
|
236
|
+
#
|
237
|
+
def rename_vob
|
238
|
+
puts "----- output vob file -----"
|
239
|
+
|
240
|
+
@vrdisc.vob_titles.each do |file_title|
|
241
|
+
src, dst = file_title
|
242
|
+
|
243
|
+
if File.exist?("#{dst}")
|
244
|
+
puts "Skip => file #{dst} is exist."
|
245
|
+
else
|
246
|
+
File.rename(src, dst)
|
247
|
+
puts " file name: #{dst}"
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
# Make a list of file names to concatenate.
|
253
|
+
#
|
254
|
+
# required values:
|
255
|
+
# @vrdisc.duplicate_name, @vrdisc.output_title
|
256
|
+
#
|
257
|
+
def make_concat_list
|
258
|
+
concat_list = []
|
259
|
+
|
260
|
+
@vrdisc.duplicate_name.each do |base_name|
|
261
|
+
contents = ""
|
262
|
+
file_name = "concat_#{base_name}.txt"
|
263
|
+
|
264
|
+
names = @vrdisc.output_title.select { |x| x.match(/#{base_name}_\d\d/) }
|
265
|
+
names.each { |line| contents += %Q[file '#{line}.vob'\n] }
|
266
|
+
concat_list << [file_name, contents, base_name]
|
267
|
+
end
|
268
|
+
|
269
|
+
concat_list
|
270
|
+
end
|
271
|
+
|
272
|
+
# Concatenate Split Titles.
|
273
|
+
# This method uses FFmpeg's media file concatenation feature.
|
274
|
+
#
|
275
|
+
# required Argument:
|
276
|
+
# concat_list
|
277
|
+
#
|
278
|
+
# concat_list is Array. Includes file_name, contents, base_name.
|
279
|
+
#
|
280
|
+
# concat_list = [[file_name, contents, base_name], [file_name, contents, base_name]. .... ]
|
281
|
+
#
|
282
|
+
# @param [String] file_name concat list name.
|
283
|
+
# @param [String] contents concatenate file names.
|
284
|
+
# @param [String] base_name output vob name.
|
285
|
+
#
|
286
|
+
def concat_titles(concat_list)
|
287
|
+
puts "----- Concatenate Split Titles -----"
|
288
|
+
concat_list.each do |list|
|
289
|
+
file_name, contents, base_name = list
|
290
|
+
File.write(file_name, contents)
|
291
|
+
puts "concat list= #{file_name}"
|
292
|
+
|
293
|
+
cmd = str_concat_cmd(file_name, base_name)
|
294
|
+
puts "----- concat vob files -----"
|
295
|
+
puts "run cmd:\n #{cmd}"
|
296
|
+
system(cmd)
|
297
|
+
|
298
|
+
begin
|
299
|
+
File.delete(file_name)
|
300
|
+
rescue
|
301
|
+
p $!
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
# convert vob to mp4.
|
307
|
+
#
|
308
|
+
# required Values:
|
309
|
+
# @vrdisc.vob_titles
|
310
|
+
#
|
311
|
+
def vob2mp4
|
312
|
+
files = []
|
313
|
+
|
314
|
+
@vrdisc.vob_titles.each do |vob_title|
|
315
|
+
files << vob_title[1].gsub(/.vob/, "")
|
316
|
+
end
|
317
|
+
|
318
|
+
files.each do |file_name|
|
319
|
+
if File.exist?("#{file_name}.mp4")
|
320
|
+
puts "Skip => file #{file_name}.mp4 is exist."
|
321
|
+
else
|
322
|
+
cmd = str_convert_cmd(file_name)
|
323
|
+
puts "----- convert #{file_name}.vob to mp4 file -----"
|
324
|
+
puts "run cmd:\n #{cmd}"
|
325
|
+
system(cmd)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
def debug_view_vrdisc
|
331
|
+
@vrdisc.members.each do |member|
|
332
|
+
puts "#{member} => #{@vrdisc[member]}"
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Dvdvrconv
|
2
|
+
module Options
|
3
|
+
def self.parse(argv)
|
4
|
+
options = {}
|
5
|
+
|
6
|
+
parser = OptionParser.new do |o|
|
7
|
+
o.on_head("-v", "--version", "Show version") do |v|
|
8
|
+
options[:version] = v
|
9
|
+
o.version = Dvdvrconv::VERSION
|
10
|
+
puts o.version
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
o.on("-i", "--info", "Show file information") do |v|
|
15
|
+
options[:info] = v
|
16
|
+
end
|
17
|
+
|
18
|
+
o.on("--config=FILE", String, "Use YAML format FILE.") do |file|
|
19
|
+
options[:config_file] = file
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
remained = parser.parse!(argv)
|
25
|
+
rescue OptionParser::InvalidArgument => e
|
26
|
+
abort e.message
|
27
|
+
rescue OptionParser::MissingArgument => e
|
28
|
+
case e.args
|
29
|
+
when ["--config"]
|
30
|
+
# load_config(Dvdvrconv::DEFAULT_CONFIG_FILE)
|
31
|
+
puts "The config file has not been specified.\nUse the default configuration file. (=> #{Dvdvrconv::DEFAULT_CONFIG_FILE})"
|
32
|
+
options[:config_file] = Dvdvrconv::DEFAULT_CONFIG_FILE
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
{ opt: options }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Path for the VR_MANGR.IFO.
|
2
|
+
vr_mangr_ifo: "./test/DVD_RTAV/VR_MANGR.IFO"
|
3
|
+
|
4
|
+
# Path for the VR_MOVIE.VRO.
|
5
|
+
vr_movie_vro: "./test/DVD_RTAV/VR_MOVIE.VRO"
|
6
|
+
|
7
|
+
# Path of the dvd-vr command.
|
8
|
+
dvd_vr_cmd: "./win/dvd-vr.exe"
|
9
|
+
|
10
|
+
|
11
|
+
# customize the title name of vob files.
|
12
|
+
#
|
13
|
+
# If specify individual file names. Write "base_dst_name:" as an Array.
|
14
|
+
#
|
15
|
+
# use_customize_title: 1
|
16
|
+
# base_dst_name: ["name_one", "name_two"]
|
17
|
+
# number_list: []
|
18
|
+
# => ["name_one", "name_two"]
|
19
|
+
#
|
20
|
+
# If add a sequence number to the file name. Write "base_dst_name:" as String.
|
21
|
+
#
|
22
|
+
# use_customize_title: 2
|
23
|
+
# base_dst_name: "output_name_"
|
24
|
+
# number_list: []
|
25
|
+
# => ["output_name_01", "output_name_02", ...]
|
26
|
+
#
|
27
|
+
# If specify sequence numbers individually.
|
28
|
+
# Write "base_dst_name:" as String and Write "number_list" as an Array.
|
29
|
+
#
|
30
|
+
# use_customize_title: 3
|
31
|
+
# base_dst_name: "output_name_"
|
32
|
+
# number_list: [12, 13, 14, 15]
|
33
|
+
# => ["output_name_12", "output_name_13", "output_name_14", "output_name_15"]
|
34
|
+
#
|
35
|
+
#
|
36
|
+
# If do not want to customize the title name,
|
37
|
+
# Specify `use_customize_title: no`.
|
38
|
+
#
|
39
|
+
# use_customize_title: no
|
40
|
+
# base_dst_name: []
|
41
|
+
# number_list: []
|
42
|
+
|
43
|
+
use_customize_title: 1
|
44
|
+
base_dst_name:
|
45
|
+
- title_one
|
46
|
+
- title_two
|
47
|
+
- title_three
|
48
|
+
|
49
|
+
number_list: []
|
data/sample_my.yaml
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Path for the VR_MANGR.IFO.
|
2
|
+
vr_mangr_ifo: "./test/DVD_RTAV/VR_MANGR.IFO"
|
3
|
+
|
4
|
+
# Path for the VR_MOVIE.VRO.
|
5
|
+
vr_movie_vro: "./test/DVD_RTAV/VR_MOVIE.VRO"
|
6
|
+
|
7
|
+
# Path of the dvd-vr command.
|
8
|
+
dvd_vr_cmd: "./win/dvd-vr.exe"
|
9
|
+
|
10
|
+
|
11
|
+
# customize the title name of vob files.
|
12
|
+
#
|
13
|
+
# If specify individual file names. Write "base_dst_name:" as an Array.
|
14
|
+
#
|
15
|
+
# use_customize_title: 1
|
16
|
+
# base_dst_name: ["name_one", "name_two"]
|
17
|
+
# number_list: []
|
18
|
+
# => ["name_one", "name_two"]
|
19
|
+
#
|
20
|
+
# If add a sequence number to the file name. Write "base_dst_name:" as String.
|
21
|
+
#
|
22
|
+
# use_customize_title: 2
|
23
|
+
# base_dst_name: "output_name_"
|
24
|
+
# number_list: []
|
25
|
+
# => ["output_name_01", "output_name_02", ...]
|
26
|
+
#
|
27
|
+
# If specify sequence numbers individually.
|
28
|
+
# Write "base_dst_name:" as String and Write "number_list" as an Array.
|
29
|
+
#
|
30
|
+
# use_customize_title: 3
|
31
|
+
# base_dst_name: "output_name_"
|
32
|
+
# number_list: [12, 13, 14, 15]
|
33
|
+
# => ["output_name_12", "output_name_13", "output_name_14", "output_name_15"]
|
34
|
+
#
|
35
|
+
#
|
36
|
+
# If do not want to customize the title name,
|
37
|
+
# Specify `use_customize_title: no`.
|
38
|
+
#
|
39
|
+
# use_customize_title: no
|
40
|
+
# base_dst_name: []
|
41
|
+
# number_list: []
|
42
|
+
|
43
|
+
use_customize_title: 3
|
44
|
+
base_dst_name: my_title_
|
45
|
+
|
46
|
+
number_list: [11, 12, 13]
|
data/test-unit.yml
ADDED
data/win/cygiconv-2.dll
ADDED
Binary file
|
data/win/cygwin1.dll
ADDED
Binary file
|
data/win/dvd-vr.exe
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dvdvrconv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- icm7216
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test-unit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit-rr
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: This tool converts "vor" file on DVD-VR format disc to "vob" files.
|
42
|
+
email:
|
43
|
+
- icm7216d@gmail.com
|
44
|
+
executables:
|
45
|
+
- dvdvrconv
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/console
|
56
|
+
- bin/setup
|
57
|
+
- dvdvrconv.gemspec
|
58
|
+
- exe/dvdvrconv
|
59
|
+
- lib/dvdvrconv.rb
|
60
|
+
- lib/dvdvrconv/command.rb
|
61
|
+
- lib/dvdvrconv/dvdvr.rb
|
62
|
+
- lib/dvdvrconv/options.rb
|
63
|
+
- lib/dvdvrconv/version.rb
|
64
|
+
- sample_default_dvdvrconv.yaml
|
65
|
+
- sample_my.yaml
|
66
|
+
- test-unit.yml
|
67
|
+
- win/cygiconv-2.dll
|
68
|
+
- win/cygwin1.dll
|
69
|
+
- win/dvd-vr.exe
|
70
|
+
homepage: https://github.com/icm7216/dvdvrconv
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.4.0
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubygems_version: 3.1.4
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: DVD-VR utility
|
93
|
+
test_files: []
|