hb-runner 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ = Handbrake CLI
2
+
3
+ This is a simple YAMLized queue runner for the HandBrake Command Line Interface
4
+
5
+ For detailed (and up to date) configuration information for HandBrakeCLI run `HandBrakeCLI --help`
6
+
7
+ == Installation
8
+
9
+ $ sudo gem install hb-queue
10
+
11
+ == Usage
12
+
13
+ $ hb-runner PATH OPTIONS_FILE_NAME QUEUE_FILE_NAME
14
+
15
+ The path sets the base path for both files.
16
+ Both the OPTIONS and QUEUE files are expected in that path.
17
+ Also, the HandBrakeCLI executable should be in your path.
18
+
19
+ === Example Configuration File
20
+
21
+ video:
22
+ format: mp4
23
+ vb: 1500
24
+ maxHeight: 480
25
+ maxWidth: 640
26
+ ipod-atom: true
27
+ markers: true
28
+ two-pass: true
29
+ turbo: true
30
+
31
+ encoder: x264
32
+
33
+ x264opts:
34
+ me: umh
35
+ ref: 2
36
+ mixed_refs: 1
37
+ direct: auto
38
+ analyse: all
39
+ level: 30
40
+ cabac: 0
41
+ fast_pskip: 0
42
+
43
+ audio:
44
+ ab: 160
45
+ drc: 2.5
46
+ audio: "1"
47
+ arate: "48"
48
+ mixdown: "stereo"
49
+
50
+ === Example Queue File
51
+
52
+ - input: input
53
+ longest: true
54
+ output: output.m4v
55
+
56
+ Dependancies
57
+
58
+ * HandBrakeCLI: http://handbrake.fr
59
+
60
+ *Disclaimer*: Every time you use handbrake to steal a movie, a kitten into a wood chipper.
@@ -0,0 +1,22 @@
1
+ #! /usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../lib/hb-runner'
3
+
4
+ if ARGV.empty?
5
+ puts
6
+ puts 'Usage: hb-runner PATH OPTIONS_FILE_NAME QUEUE_FILE_NAME'
7
+ puts 'the path sets the base path for both files. Both the OPTIONS and QUEUE files are expected in that path.'
8
+ puts
9
+ puts 'Also, the HandBrakeCLI executable should be in your path.'
10
+ 3.times { puts }
11
+ else
12
+ path, options_file, queue_file = ARGV
13
+
14
+ path ||= File.expand_path File.dirname(__FILE__)
15
+ options_file ||= 'hb_config.yml'
16
+ queue_file ||= 'hb_queue.yml'
17
+
18
+ options = HBConfig.new :path => path, :file => options_file
19
+ queue = HBQueue.new :path => path, :file => queue_file, :options => options
20
+
21
+ queue.run
22
+ end
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__)
2
+
3
+ require 'hb-runner/yaml_config'
4
+ require 'hb-runner/hb_config'
5
+ require 'hb-runner/hb_queue'
6
+
@@ -0,0 +1,21 @@
1
+ # This class processes a YAML file of Handbrake Options
2
+ # and can return it as a properly formatted string
3
+ #
4
+ class HBConfig < YAMLConfig
5
+
6
+ attr_accessor :options
7
+
8
+ def read
9
+ if data['video'].keys.include?('x264opts')
10
+ data['video']['x264opts'] = data['video']['x264opts'].map {|k,v| "#{k}=#{v}"}.join(':')
11
+ end
12
+
13
+ @options = data
14
+ self.to_s
15
+ end
16
+
17
+ def to_s
18
+ @options.map {|o| o.last.map { |k,v| "--#{k} #{v.inspect}" }.join(' ') }.join.gsub('true', '')
19
+ end
20
+
21
+ end
@@ -0,0 +1,43 @@
1
+ # This class processes a yaml file queue of items
2
+ # with handbrake, using the given HBConfig configuration
3
+ #
4
+ class HBQueue < YAMLConfig
5
+ attr_accessor :queue
6
+
7
+ def read
8
+ @queue = data
9
+ "#{@queue.size} item(s) in the queue."
10
+ end
11
+
12
+ def run
13
+ queue.each do |item|
14
+
15
+ item_options = {
16
+ :input => File.expand_path(File.join(path, item['input'])),
17
+ :output => File.expand_path(File.join(path, item['output'])),
18
+ :chapters => item['chapters']
19
+ }.map {|k,v| "--#{k} #{v.inspect}" }.join(' ')
20
+
21
+ execute "HandBrakeCLI #{item_options} #{@options}"
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def execute command
28
+ 5.times { puts }
29
+ puts 'Starting!'
30
+ puts
31
+
32
+ IO.popen(command) do |output|
33
+ begin
34
+ puts line while line = output.gets
35
+ rescue
36
+ puts 'Finished!'
37
+ end
38
+ end
39
+
40
+ 5.times { puts }
41
+ end
42
+
43
+ end
@@ -0,0 +1,28 @@
1
+ require 'yaml'
2
+
3
+ # this class DRYs up the yaml processing code
4
+ # for both HBQueue and HBConfig
5
+ #
6
+ class YAMLConfig
7
+ attr_accessor :path, :file
8
+
9
+ def initialize options = {}
10
+ options.each { |k,v| instance_variable_set "@#{k}", v }
11
+ read
12
+ end
13
+
14
+ def filename() File.join path, file end
15
+
16
+ def data
17
+ unless File.exist?(filename)
18
+ puts "Unable to open #{self.class.name} file #{filename}!"
19
+ Process.exit
20
+ end
21
+
22
+ open(filename) { |f| YAML.load f }
23
+ end
24
+
25
+ def read() raise 'Override!' end
26
+ def to_s() raise 'Override!' end
27
+
28
+ end
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'elif'
4
+
5
+ # last_line = `tail -n 1 #{file_name}`
6
+
7
+ last_line = Elif.open('output.txt') { |f| f.gets }
8
+
9
+ puts "The last line is #{last_line}!"
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hb-runner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors: []
7
+
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-05 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email:
18
+ executables:
19
+ - hb-runner
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - lib/hb-runner/hb_config.rb
26
+ - lib/hb-runner/hb_queue.rb
27
+ - lib/hb-runner/yaml_config.rb
28
+ - lib/hb-runner.rb
29
+ - lib/parse.rb
30
+ - README.rdoc
31
+ has_rdoc: true
32
+ homepage:
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options: []
37
+
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.3.5
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: HandbrakeCLI queue / config tool
59
+ test_files: []
60
+