vollbremsung 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjE4MzlmZDc2NjZkNTVhZmMwOTMwOWJmZmJjYjIzNDYyYzRiYWI3Mw==
4
+ YzVmYjQzOGM0N2ZhOGM3MzJhOTRkNzAzNjg4MmQ5ZjE2N2U0YzlmNw==
5
5
  data.tar.gz: !binary |-
6
- YTExYTMwODFhYzBjZjI3NzQzZDJlMWRmOTgxNTcyZGRlZTBkNzEwZQ==
6
+ Y2VmZDhmYmVmYTU3YTgwZDFmNDYxM2FiZTk4ZGZkMzNlMjExNjQxYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGNjNWE0NDZlMDU5MTY5NTFkYjIxNzFiOTE4YzdjODk0ODRjMTQ2ODRkNjEy
10
- NmI0MDIxNTY3MWIyNTdlYzllOGRhZTczMzllMjIzOWVlOGIzYzFjYWRhYmI0
11
- YmMxZWZiOTY1NmZlNmY3ZmM2OGE2MDA2NmU4MTNjZDJlZTVhODk=
9
+ NWY0MGM2MTE3MTJmNDg2MTgyOTA1ZWIyOTEyYmFiYzcwNmZlNzRhMTVkMjU4
10
+ ZDU0ZWI2MWE2ZTM0ZGJmOWRjNGIyZDUzMDhiM2VlMjI3NjU5ZTNhNGNlOTBm
11
+ MDBlMjU1MDc5YWYzYzRhNjJlZmJhYWM2ODFiNDI0MGYwZWI4MWU=
12
12
  data.tar.gz: !binary |-
13
- ODQ2NzdjMDg2NjMwZWY4ZGU2YTcyZTg0MjYxMjZlYmM3NDM5MWEwYzhmNzdm
14
- ZGViNzc2OTI4NzY0NGYzYjJjZGUzMDgyNTRjZDQ4Y2ZiMGM3M2MzNDE3YWUw
15
- MDllODBmNzZkY2U2OGJhOTM2ZWQ1MjFkM2Q3NzliMzNlZjNlZDM=
13
+ YmE4ZDdhZThkYTJlMjZlNDQ4NWNhZjI5NzliYzliNzM2MDYzZDAxMzI4ZTNk
14
+ ZGFhYjhjNzI0MGI1NTVjOWI2NDYzNmE1NzAxYmFmMDFhZTZhZTQxZDNjNDdj
15
+ MjJkYWZjYzFkNDE0ZmQ1NDg2MmFjYmM3MDg0NDE2OGZkZGFhMjY=
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Maximilian Irro
3
+ Copyright (c) 2014-2015 Maximilian Irro
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
data/README.md CHANGED
@@ -15,25 +15,28 @@ You need to have `ffmpeg`, `ffprobe` and `HandbrakeCLI` (on FreeBSD it's `HandBr
15
15
  ## Usage
16
16
 
17
17
  vollbremsung [options] target [target [...]]
18
-
19
- It takes target paths and probes them for suited files. If a target path is a file, it is the only match, if it is a directory all containing files with a matching file type (basically all the non MP4 multimedia types like .avi, .flv, .mov, etc.) are taken. The `--recursive` option will extend the search scope to probe the subfiletree as well. It furthermore analyses each file for its structure utilising [ffmpegs](https://www.ffmpeg.org) `ffprobe` tool in order to extend Handbrakes default preset, processing *all* audio and subtitle tracks, not only the first ones.
18
+
19
+ It takes target paths and probes them for suited files. If a target path is a file, it is the only match, if it is a directory all containing files with a matching file type (basically all the non MP4 multimedia types like .avi, .flv, .mov, etc.) are taken. The `--recursive` option will extend the search scope to probe the sub filetree as well. It furthermore analyses each file for its structure utilising [ffmpegs](https://www.ffmpeg.org) `ffprobe` tool in order to extend Handbrakes default preset, processing *all* audio and subtitle tracks, not only the first ones.
20
20
 
21
21
  The video streams will be converted to h.264 while audio streams will enjoy the AAC codec. Every DLNA enabled TV should be able to handle these two.
22
22
 
23
23
  The `x264-preset ` used is `veryfast` which should be a good tradeoff most of the time. If you want to change this manually, use the `--x264-preset [PRESET]` option.
24
24
 
25
- The `--delete` and `--move` option allow post processing actions. `delete` will of course remove the source file upon successfull processing, while `move ` will add a `.old` file extension for archive purposes. This is always a good option, just to be sure.
25
+ The `--delete` and `--move` option allow post processing actions. `delete` will of course remove the source file upon successful processing, while `move ` will add a `.old` file extension for archive purposes. This is always a good option, just to be sure.
26
26
 
27
- Additionally, `vollbremsung` can set the MP4 title tag to the filename via the `--title` option, in case the old file title metadata is somewhat misshampen.
27
+ Additionally, `vollbremsung` can set the MP4 title tag to the filename via the `--title` option, in case the old file title metadata is somewhat misshapen.
28
28
 
29
29
  Per default the `m4v` file extension is used to indicate that the files contain video content. It turned out that some TVs can't handle this extension and require plain `mp4`. The `--mp4-ext` option will make `vollbremsung` create `mp4` files. You can of course rename the output files manually as well.
30
30
 
31
- If you only want to know which files would match for a given target, use the `--list-only` option. No processing will be done, just the matches printed.
32
-
31
+ If you only want to know which files would match for a given target, use the `--list-only` option. No processing will be done, just the matches printed.
32
+
33
+ In order to only match a given range of file extensions, the `--match` option accepts a comma separated list of file extensions which will replace the default match scope. Thereby this can be used to extend the matching extensions in fact by just reusing the list printed from `--help` and adding extensions.
34
+
33
35
  ### Complete list of options
34
36
 
35
37
  -d, --delete Delete source files after successful encoding
36
38
  --list-only List matching files only. Do not run processing
39
+ --match ext1,ext2,ext3 Match only specific file extensions
37
40
  --mp4-ext Use 'mp4' as file extension instead of 'm4v'
38
41
  -m, --move Move source files to <FILENAME>.old after encoding
39
42
  -r, --recursive Process subdirectories recursively as well
@@ -41,7 +44,70 @@ If you only want to know which files would match for a given target, use the `--
41
44
  --x264-preset PRESET Set the x264-preset. Default is: veryfast
42
45
  --version Show program version information
43
46
  -h, --help Show this message
44
-
47
+
45
48
  ## Etymology
46
49
 
47
50
  "*vollbremsung*" means "*full application of the brake*" in german.
51
+
52
+ ## Changelog
53
+
54
+ **0.0.21**
55
+
56
+ + Added the `--match` option.
57
+
58
+ **0.0.20**
59
+
60
+ + Added `.webm` to the matching file extensions.
61
+
62
+ **0.0.19**
63
+
64
+ + Delete temporary file when mp4 title could not be changed.
65
+
66
+ **0.0.18**
67
+
68
+ + Fixed a bug with multiple target directories where all but the first target were not probed correctly.
69
+
70
+ **0.0.17**
71
+
72
+ + Added support for multiple targets.
73
+ + Added option for `mp4` as file extension instead of `m4v`.
74
+ + Fixed a bug which made the `PRESET` agrument of `--x264-preset` optional (and the option thereby useless).
75
+
76
+ **0.0.16**
77
+
78
+ + Fixed a bug when probing files with square braces in their path.
79
+ + Fixed a bug where file names where not correctly extracted from the files path and the files extension.
80
+
81
+ **0.0.14**
82
+
83
+ + Fixed the bug that **0.0.13** should have fixed.
84
+
85
+ **0.0.13**
86
+
87
+ + Fixed a bug which did not output the correct relative path of a file based on the target path.
88
+
89
+ **0.0.12**
90
+
91
+ + Changed audio codec to AAC only. AC3, DTSHD, DTS and MP3 will no longer be carried on any more.
92
+ + Changed file extension of the output files to `m4v`.
93
+
94
+ **0.0.11**
95
+
96
+ + Improved help message.
97
+ + Fixed a bug where target paths ending with a / where not proved correctly.
98
+
99
+ **0.0.10**
100
+
101
+ + Added an option to show the program version number.
102
+ + Added a descent help message.
103
+
104
+ **0.0.9**
105
+
106
+ + Added `.ogm` to the matching file extensions.
107
+ + Added a specific handbrake gem version to the dependencies.
108
+ + Added `--list-only` option.
109
+ + Added `--x264-preset` option.
110
+
111
+ **0.0.8**
112
+
113
+ + Turned the simple ruby script to a RubyGem.
data/bin/vollbremsung CHANGED
@@ -29,7 +29,10 @@ def escape_glob(s)
29
29
  s.gsub(/[\\\{\}\[\]\*\?]/) { |x| "\\"+x }
30
30
  end
31
31
 
32
- options = { :extension => "m4v" }
32
+ options = {
33
+ :extension => "m4v",
34
+ :match_list => Vollbremsung::CONVERT_TYPES
35
+ }
33
36
 
34
37
  OptionParser.new do |opts|
35
38
  opts.banner = Vollbremsung::USAGE
@@ -52,11 +55,15 @@ OptionParser.new do |opts|
52
55
  opts.on("--list-only", "List matching files only. Do not run processing") do |flag|
53
56
  options[:list_only] = true
54
57
  end
55
-
58
+
59
+ opts.on("--match ext1,ext2,ext3", String, "Match only specific file extensions") do |es|
60
+ options[:match_list] = es.split(',')
61
+ end
62
+
56
63
  opts.on("--mp4-ext", "Use 'mp4' as file extension instead of 'm4v'") do |flag|
57
64
  options[:extension] = "mp4"
58
65
  end
59
-
66
+
60
67
  opts.on("-m", "--move", "Move source files to <FILENAME>.old after encoding") do |flag|
61
68
  options[:move] = true
62
69
  end
@@ -68,11 +75,11 @@ OptionParser.new do |opts|
68
75
  opts.on("-t", "--title", "Set the MP4 metadata title tag to the filename") do |flag|
69
76
  options[:title] = true
70
77
  end
71
-
72
- opts.on("--x264-preset PRESET", "Set the x264-preset. Default is: #{Vollbremsung::X264_DEFAULT_PRESET}") do |preset|
78
+
79
+ opts.on("--x264-preset PRESET", String, "Set the x264-preset. Default is: #{Vollbremsung::X264_DEFAULT_PRESET}") do |preset|
73
80
  options[:x264_preset] = preset
74
81
  end
75
-
82
+
76
83
  opts.on("--version", "Show program version information") do
77
84
  options[:version] = true
78
85
  end
@@ -93,7 +100,7 @@ end
93
100
  options[:x264_preset] = Vollbremsung::X264_DEFAULT_PRESET if options[:x264_preset].nil?
94
101
 
95
102
 
96
- if ARGV[0].nil?
103
+ if ARGV[0].nil?
97
104
  puts "No target provided."
98
105
  puts Vollbremsung::USAGE
99
106
  exit 1
@@ -120,7 +127,7 @@ unless options[:list_only]
120
127
  unless find_executable('HandbrakeCLI') || find_executable('HandBrakeCLI')
121
128
  puts "It seems you do not have HandbrakeCLI installed or it is not available in your $PATH."
122
129
  puts "You can get the executable from http://handbrake.fr/downloads.php"
123
-
130
+
124
131
  File.delete 'mkmf.log' if File.exists?('mkmf.log') # find_executable seems to create such file in case executable is not found
125
132
  exit 1
126
133
  end
@@ -128,51 +135,48 @@ unless options[:list_only]
128
135
  unless find_executable 'ffprobe'
129
136
  puts "It seems you do not have ffprobe installed or it is not available in your $PATH."
130
137
  puts "ffprobe is part of ffmpeg. Install it for your system and run again."
131
-
138
+
132
139
  File.delete 'mkmf.log' if File.exists?('mkmf.log') # find_executable seems to create such file in case executable is not found
133
140
  exit 1
134
141
  end
135
-
142
+
136
143
  File.delete 'mkmf.log' if File.exists?('mkmf.log') # find_executable seems to create such file in case executable is not found
137
144
  end
138
145
 
139
146
 
140
-
141
-
142
147
  #HANDBRAKE_OPTIONS = "--encoder x264 --quality 20.0 --aencode faac -B 160 --mixdown dpl2 --arate Auto -D 0.0 --format mp4 --markers --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 --x264-preset veryfast --loose-anamorphic --modulus 2"
143
148
 
144
149
 
145
150
  target_files = []
146
-
147
151
  scope = options[:recursive] ? "/**/*" : "/*"
148
152
 
149
153
  ARGV.each do |target|
150
154
 
151
155
  if File.directory?(target)
152
-
156
+
153
157
  log "probing for target files in #{File.absolute_path(target) + scope}"
154
158
  log "files found:"
155
-
159
+
156
160
  Dir[escape_glob(File.absolute_path(target)) + scope].sort.each do |file|
157
161
  unless File.directory?(file)
158
- if Vollbremsung::CONVERT_TYPES.include?(File.extname(file).downcase[1..-1])
159
- puts "* " + File.absolute_path(file)[File.absolute_path(target).length+1..-1]
160
- target_files << [file,target] # file and provided target_dir
162
+ if options[:match_list].include?(File.extname(file).downcase[1..-1])
163
+ puts "* " + File.absolute_path(file)[File.absolute_path(target).length+1..-1]
164
+ target_files << [file,target] # file and provided target_dir
161
165
  end
162
166
  end
163
167
  end
164
-
168
+
165
169
  else
166
170
  puts "* " + target
167
171
  target_files << [File.absolute_path(target),File.absolute_path(target)]
168
172
  end
169
-
173
+
170
174
  end
171
175
 
172
176
  exit if options[:list_only]
173
177
 
174
178
  target_files.each do |infile, target_dir|
175
-
179
+
176
180
  metadata = ffprobe(infile)
177
181
  if metadata.nil?
178
182
  log "ERROR retrieving metadata -- skipping this file"
@@ -181,38 +185,38 @@ target_files.each do |infile, target_dir|
181
185
 
182
186
  astreams = Vollbremsung::StreamDescr.new
183
187
  sstreams = Vollbremsung::StreamDescr.new
184
-
188
+
185
189
  metadata['streams'].each do |stream|
186
190
  case stream['codec_type']
187
- when 'audio'
191
+ when 'audio'
188
192
  astreams.count += 1
189
193
  astreams.names << stream['tags']['title'] unless stream['tags'].nil? || stream['tags']['title'].nil?
190
- when 'subtitle'
194
+ when 'subtitle'
191
195
  sstreams.count += 1
192
196
  sstreams.names << stream['tags']['title'] unless stream['tags'].nil? || stream['tags']['title'].nil?
193
- else
197
+ else
194
198
  # this is attachment stuff, like typefonts --> ignore
195
199
  end
196
200
  end
197
201
 
198
-
202
+
199
203
  infile_basename = File.basename(infile)
200
204
  infile_basename_noext = File.basename(infile, File.extname(infile)) # without ext
201
205
  infile_dirname = File.dirname(infile)
202
206
  infile_path_noext = File.join(infile_dirname, infile_basename_noext)
203
207
  infile_relative_path = #File.directory?(TARGET_PATH) ? infile[TARGET_PATH.length+1..-1] : File.basename(TARGET_PATH)
204
208
  if File.directory?(target_dir)
205
- File.absolute_path(infile)[File.absolute_path(target_dir).length+1..-1]
209
+ File.absolute_path(infile)[File.absolute_path(target_dir).length+1..-1]
206
210
  else
207
211
  File.basename(target_dir)
208
212
  end
209
213
 
210
214
  outfile = "#{infile_path_noext}.#{options[:extension]}"
211
-
212
- log "processing: #{infile_relative_path}"
215
+
216
+ log "processing: #{infile_relative_path}"
213
217
 
214
218
  #%x( #{HANDBRAKE_CLI} #{HANDBRAKE_OPTIONS} --audio #{(1..astreams.count).to_a.join(',')} --aname #{astreams.names.join(',')} --subtitle #{(1..sstreams.count).to_a.join(',')} -i \"#{infile}\" -o \"#{outfile}\" 2>&1 )
215
-
219
+
216
220
  success = false
217
221
  begin
218
222
  HandBrake::CLI.new.input(infile).encoder('x264').quality('20.0').aencoder('faac').
@@ -220,32 +224,32 @@ target_files.each do |infile, target_dir|
220
224
  audio_copy_mask('aac').audio_fallback('ffac3').x264_preset(options[:x264_preset]).
221
225
  loose_anamorphic.modulus('2').audio((1..astreams.count).to_a.join(',')).aname(astreams.names.join(',')).
222
226
  subtitle((1..sstreams.count).to_a.join(',')).output(outfile)
223
-
227
+
224
228
  # if we make it here, encoding went well
225
229
  log "SUCCESS: encoding done"
226
230
  success = true
227
- rescue
231
+ rescue
228
232
  log "ERROR: Handbrake exited with an error"
229
233
  end # HandBrake::CLI
230
-
234
+
231
235
  if success
232
236
  infile_size = File.size(infile)
233
237
  outfile_size = File.size(outfile)
234
238
 
235
239
  log "compression ratio: %.2f" % (outfile_size.to_f / infile_size.to_f)
236
-
240
+
237
241
  if options[:title]
238
242
  log "setting MP4 title"
239
-
243
+
240
244
  infile_noext = File.join( File.dirname(infile), File.basename(infile,File.extname(infile)))
241
245
  tmpfile = infile_noext + ".tmp.mp4"
242
-
246
+
243
247
  %x( ffmpeg -i \"#{outfile}\" -metadata title=\"#{infile_basename_noext}\" #{Vollbremsung::FFMPEG_OPTIONS} \"#{tmpfile}\" 2>&1 )
244
-
248
+
245
249
  if $?.exitstatus == 0
246
250
  begin
247
251
  File.delete outfile
248
- File.rename tmpfile, outfile
252
+ File.rename tmpfile, outfile
249
253
  rescue
250
254
  log "ERROR: moving #{tmpfile} to #{outfile}"
251
255
  end
@@ -254,7 +258,7 @@ target_files.each do |infile, target_dir|
254
258
  File.delete tmpfile
255
259
  end
256
260
  end # if options[:title]
257
-
261
+
258
262
  if options[:move]
259
263
  log "moving source file to *.old"
260
264
  File.rename(infile, "#{infile}.old") rescue log "ERROR: renaming source file"
@@ -262,7 +266,7 @@ target_files.each do |infile, target_dir|
262
266
  log "deleting source file"
263
267
  File.delete(infile) rescue log "ERROR: deleting source file"
264
268
  end
265
-
269
+
266
270
  end # if success
267
271
  end # target_files.each
268
272
 
data/lib/vollbremsung.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  module Vollbremsung
2
-
2
+
3
3
  USAGE = "Usage: vollbremsung [options] target [target [...]]"
4
- VERSION = '0.0.20'.freeze
4
+ VERSION = '0.0.21'.freeze
5
5
  CONVERT_TYPES = ['avi','flv','mkv','mpg','mov','ogm','webm','wmv']
6
6
  FFMPEG_OPTIONS = "-map 0 -acodec copy -vcodec copy -scodec copy"
7
7
  X264_DEFAULT_PRESET = "veryfast".freeze
8
-
8
+
9
9
  class StreamDescr < Struct.new(:count,:names)
10
10
  def initialize
11
11
  super(0,[])
12
12
  end
13
13
  end
14
-
15
- end
14
+
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vollbremsung
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maximilian Irro