vtools 0.0.1 → 0.0.2
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.
- data/README.md +5 -4
- data/Rakefile +2 -2
- data/doc/LIB_EXAMPLE.md +4 -3
- data/lib/vtools/convert_options.rb +0 -1
- data/lib/vtools/converter.rb +0 -1
- data/lib/vtools/handler.rb +5 -5
- data/lib/vtools/job.rb +2 -4
- data/lib/vtools/storage.rb +4 -5
- data/lib/vtools/thumbnailer.rb +0 -1
- data/lib/vtools/thumbs_options.rb +0 -2
- data/lib/vtools/version.rb +1 -1
- data/lib/vtools/video.rb +3 -9
- data/spec/convert_options_spec.rb +1 -1
- data/spec/thumbs_options_spec.rb +1 -1
- data/spec/video_spec.rb +1 -1
- data/vtools.gemspec +1 -1
- metadata +73 -83
- data/lib/vtools/version.rb~ +0 -4
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# VTools
|
2
2
|
|
3
|
-
Daemon
|
3
|
+
Daemon tools to operate the video (get info, encode & generate thumbnails).
|
4
4
|
Under the hood ffmpeg & ffmpegthumbnailer are used.
|
5
5
|
Some ideas has been taken at the streamio-ffmpeg gem (parse output methods).
|
6
6
|
|
@@ -10,13 +10,13 @@ Project was developed for the [WebTV](http://web.tv)
|
|
10
10
|
|
11
11
|
(sudo) gem install vtools
|
12
12
|
|
13
|
-
Please read changelog to check ffmpeg versions compatibility.
|
13
|
+
Please read changelog to check ffmpeg versions compatibility (vtools understands 0.7 & 0.8).
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
17
|
### Getting started
|
18
18
|
|
19
|
-
Before start, daemon should be correctly
|
19
|
+
Before start, daemon should be configured correctly, to have valid access to the storage.
|
20
20
|
Mandatory methods are: **connect**, **recv** and **send**.
|
21
21
|
|
22
22
|
``` ruby
|
@@ -82,7 +82,7 @@ thumbnailer (ffmpegthumbnailer)
|
|
82
82
|
|
83
83
|
## Start
|
84
84
|
|
85
|
-
To launch daemon is enough to require library with storage setup:
|
85
|
+
To launch daemon - is enough to require library with storage setup:
|
86
86
|
(sudo) vtools start -- -r library
|
87
87
|
|
88
88
|
## Options
|
@@ -116,6 +116,7 @@ It accepts file name and should return relative path (excluding file name itself
|
|
116
116
|
# path generator (used to )
|
117
117
|
VTools.path_generator do |file_name|
|
118
118
|
# ..
|
119
|
+
"#{file_name[0..2]}/{file_name[2..4]}"
|
119
120
|
end
|
120
121
|
|
121
122
|
```
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ require "vtools/version"
|
|
8
8
|
spec = Gem::Specification.new do |s|
|
9
9
|
s.name = "vtools"
|
10
10
|
s.summary = "Daemon tools to operate the video (get info, encode & generate thumbnails)."
|
11
|
-
s.description =
|
11
|
+
s.description = "Daemon tools to operate the video (get info, encode & generate thumbnails)."
|
12
12
|
s.extensions = 'extconf.rb'
|
13
13
|
s.version = VTools::VERSION.join('.')
|
14
14
|
s.requirements = ['ffmpeg v >= 1.8', 'ffmpegthumbnailer v >= 2', 'gem Daemons v >= 1.1.4']
|
@@ -26,4 +26,4 @@ spec = Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency 'rspec'
|
27
27
|
end
|
28
28
|
|
29
|
-
Rake::GemPackageTask.new(spec).define
|
29
|
+
Rake::GemPackageTask.new(spec).define
|
data/doc/LIB_EXAMPLE.md
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
Library can be required via `-r` option
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
$ vtools start -- -r library
|
6
|
+
|
7
|
+
$ vtools start -- -r library.rb
|
7
8
|
|
8
9
|
```ruby
|
9
10
|
# -*- encoding: binary -*-
|
@@ -106,4 +107,4 @@ VTools::Handler.collection do
|
|
106
107
|
print "(#{video.name}) <------ job |finished | {#{video}} :: scope: #{action}\n"
|
107
108
|
end
|
108
109
|
end
|
109
|
-
```
|
110
|
+
```
|
data/lib/vtools/converter.rb
CHANGED
data/lib/vtools/handler.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module VTools
|
4
4
|
|
5
|
-
#
|
6
|
-
# allows to execute external script
|
7
|
-
# multiple
|
5
|
+
# hooks handler
|
6
|
+
# allows to execute hooks from external script
|
7
|
+
# multiple hooks in one placeholder are allowed
|
8
8
|
#
|
9
9
|
# usage:
|
10
10
|
# Handler.set :placeholder_name, &block
|
@@ -19,14 +19,14 @@ module VTools
|
|
19
19
|
@callbacks = {}
|
20
20
|
|
21
21
|
class << self
|
22
|
-
#
|
22
|
+
# hooks setter
|
23
23
|
def set action, &block
|
24
24
|
action = action.to_sym
|
25
25
|
@callbacks[action] = [] unless @callbacks[action].is_a? Array
|
26
26
|
@callbacks[action] << block if block_given?
|
27
27
|
end
|
28
28
|
|
29
|
-
# pending
|
29
|
+
# pending hooks exectuion
|
30
30
|
def exec action, *args
|
31
31
|
action = action.to_sym
|
32
32
|
@callbacks[action].each do |block|
|
data/lib/vtools/job.rb
CHANGED
@@ -6,7 +6,6 @@ module VTools
|
|
6
6
|
class Job
|
7
7
|
attr_reader :video, :id
|
8
8
|
|
9
|
-
# constructor
|
10
9
|
def initialize config
|
11
10
|
@id = self.object_id.to_i
|
12
11
|
@config = validate config
|
@@ -15,7 +14,7 @@ module VTools
|
|
15
14
|
|
16
15
|
# execute job
|
17
16
|
def execute
|
18
|
-
# start
|
17
|
+
# start hook
|
19
18
|
Handler.exec :job_started, @video, @config.action
|
20
19
|
|
21
20
|
result = @video.get_info # we always get info
|
@@ -27,7 +26,7 @@ module VTools
|
|
27
26
|
result = @video.create_thumbs @config.setup # will return thumbs array
|
28
27
|
end
|
29
28
|
|
30
|
-
# final
|
29
|
+
# final hook
|
31
30
|
Handler.exec :job_finished, result, @video, @config.action
|
32
31
|
result
|
33
32
|
end
|
@@ -43,6 +42,5 @@ module VTools
|
|
43
42
|
end
|
44
43
|
options
|
45
44
|
end
|
46
|
-
|
47
45
|
end # Job
|
48
46
|
end # VTools
|
data/lib/vtools/storage.rb
CHANGED
@@ -10,19 +10,19 @@ module VTools
|
|
10
10
|
|
11
11
|
class << self
|
12
12
|
|
13
|
-
#
|
13
|
+
# creates connection
|
14
14
|
def connect
|
15
15
|
fails __method__ unless @actions[:connect]
|
16
16
|
@actions[:connect].call
|
17
17
|
end
|
18
18
|
|
19
|
-
#
|
19
|
+
# receive basic method
|
20
20
|
def recv
|
21
21
|
fails __method__ unless @actions[:recv]
|
22
22
|
@actions[:recv].call
|
23
23
|
end
|
24
24
|
|
25
|
-
# send
|
25
|
+
# send basic method
|
26
26
|
def send data
|
27
27
|
fails __method__ unless @actions[:send]
|
28
28
|
@actions[:send].call(data)
|
@@ -33,7 +33,7 @@ module VTools
|
|
33
33
|
@actions[:connect] = block
|
34
34
|
end
|
35
35
|
|
36
|
-
# callback setter to
|
36
|
+
# callback setter to receive data
|
37
37
|
def recv_action &block
|
38
38
|
@actions[:recv] = block
|
39
39
|
end
|
@@ -59,7 +59,6 @@ module VTools
|
|
59
59
|
private
|
60
60
|
# errors generator
|
61
61
|
def fails meth
|
62
|
-
p "fails orig: #{meth}"
|
63
62
|
raise NotImplementedError, "VTools::Storage##{meth}_action must be set"
|
64
63
|
end
|
65
64
|
end # class << self
|
data/lib/vtools/thumbnailer.rb
CHANGED
@@ -6,7 +6,6 @@ module VTools
|
|
6
6
|
class ThumbsOptions < Hash
|
7
7
|
include SharedMethods
|
8
8
|
|
9
|
-
# constructor
|
10
9
|
def initialize options = {}
|
11
10
|
|
12
11
|
@ignore = [:thumb_count, :thumb_start_point, :quality, :width, :time, :postfix]
|
@@ -36,7 +35,6 @@ module VTools
|
|
36
35
|
value
|
37
36
|
end
|
38
37
|
|
39
|
-
# to string
|
40
38
|
def to_s
|
41
39
|
params = collect do |key, value|
|
42
40
|
"-#{key} #{value}" unless @ignore.include?(key)
|
data/lib/vtools/version.rb
CHANGED
data/lib/vtools/video.rb
CHANGED
@@ -11,7 +11,6 @@ module VTools
|
|
11
11
|
:audio_sample_rate,
|
12
12
|
:convert_options, :thumbs_options
|
13
13
|
|
14
|
-
# json generator
|
15
14
|
def to_json(*args)
|
16
15
|
ignore = [:@convert_options, :@thumbs_options, :@converter, :@thumbnailer, :@uncertain_duration, :invalid]
|
17
16
|
|
@@ -24,7 +23,6 @@ module VTools
|
|
24
23
|
hsh.to_json(*args)
|
25
24
|
end
|
26
25
|
|
27
|
-
# constructor
|
28
26
|
def initialize path
|
29
27
|
|
30
28
|
@invalid = true
|
@@ -97,8 +95,7 @@ module VTools
|
|
97
95
|
|
98
96
|
self
|
99
97
|
end
|
100
|
-
|
101
|
-
# define if is valid video file
|
98
|
+
|
102
99
|
def valid?
|
103
100
|
not @invalid
|
104
101
|
end
|
@@ -108,17 +105,15 @@ module VTools
|
|
108
105
|
@uncertain_duration
|
109
106
|
end
|
110
107
|
|
111
|
-
# width getter
|
112
108
|
def width
|
113
109
|
resolution.split("x").first.to_i rescue nil
|
114
110
|
end
|
115
111
|
|
116
|
-
# height getter
|
117
112
|
def height
|
118
113
|
resolution.split("x").last.to_i rescue nil
|
119
114
|
end
|
120
115
|
|
121
|
-
# aspect ratio
|
116
|
+
# aspect ratio calculator
|
122
117
|
def calculated_aspect_ratio
|
123
118
|
if dar
|
124
119
|
w, h = dar.split(":")
|
@@ -134,7 +129,7 @@ module VTools
|
|
134
129
|
File.size(@path)
|
135
130
|
end
|
136
131
|
|
137
|
-
# audio channels
|
132
|
+
# valid audio channels index
|
138
133
|
def audio_channels
|
139
134
|
return nil unless @audio_channels
|
140
135
|
return @audio_channels[/\d*/].to_i if @audio_channels["channels"]
|
@@ -143,7 +138,6 @@ module VTools
|
|
143
138
|
return 6 if @audio_channels["5.1"]
|
144
139
|
end
|
145
140
|
|
146
|
-
# frame rate getter
|
147
141
|
def frame_rate
|
148
142
|
video_stream[/(\d*\.?\d*)\s?fps/] ? $1.to_f : nil
|
149
143
|
end
|
data/spec/thumbs_options_spec.rb
CHANGED
@@ -68,7 +68,7 @@ describe VTools::ThumbsOptions do
|
|
68
68
|
|
69
69
|
# [:thumb_count, :thumb_start_point, :quality, :width, :time, :postfix]
|
70
70
|
# skps ignored values
|
71
|
-
it "
|
71
|
+
it "creates valid string representation" do
|
72
72
|
|
73
73
|
# still empty
|
74
74
|
@options.to_s.should == ""
|
data/spec/video_spec.rb
CHANGED
data/vtools.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
|
8
8
|
s.name = "vtools"
|
9
9
|
s.summary = "Daemon tools to operate the video (get info, encode & generate thumbnails)."
|
10
|
-
s.description =
|
10
|
+
s.description = "Daemon tools to operate the video (get info, encode & generate thumbnails)."
|
11
11
|
|
12
12
|
s.extensions = 'extconf.rb'
|
13
13
|
s.requirements = ['ffmpeg v >= 1.8', 'ffmpegthumbnailer v >= 2', 'gem Daemons v >= 1.1.4']
|
metadata
CHANGED
@@ -1,93 +1,75 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vtools
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- tofir
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2011-11-23 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: daemons
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 27
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 1
|
32
|
+
- 4
|
21
33
|
version: 1.1.4
|
22
34
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
26
37
|
name: json
|
27
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
40
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
33
48
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
37
51
|
name: rspec
|
38
|
-
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
54
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
44
62
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
description: ! "# VTools\n\nDaemon video processor tools to operate the video (get
|
48
|
-
info, encode & generate thumbnails).\nUnder the hood ffmpeg & ffmpegthumbnailer
|
49
|
-
are used.\nSome ideas has been taken at the streamio-ffmpeg gem (parse output methods).\n\nProject
|
50
|
-
was developed for the [WebTV](http://web.tv)\n\n## Installation\n\n (sudo) gem
|
51
|
-
install vtools\n\nPlease read changelog to check ffmpeg versions compatibility.\n\n##
|
52
|
-
Usage\n\n### Getting started\n\nBefore start, daemon should be correctly configured,
|
53
|
-
to have valid access to the storage.\nMandatory methods are: **connect**, **recv**
|
54
|
-
and **send**.\n\n``` ruby\n#--file library.rb--#\n# encoding: binary\n\n#to setup
|
55
|
-
storage:\nVTools::Storage.setup do\n\n # connection setup\n connect_action do\n
|
56
|
-
\ # ... connect to the storage (persistent)\n end\n\n # message reciever\n #
|
57
|
-
should return JSON encoded string\n # see complete storage setup reference for
|
58
|
-
details\n recv_action do\n # ... job data recieve algorithm\n end\n\n # message
|
59
|
-
sender\n # recieves hash: { :data => execution_result, :action => executed_action
|
60
|
-
}\n # execution_result can be video object or array with thumbnails\n send_action
|
61
|
-
do |result|\n # ... send action here\n end\nend\n\n# storage can be setup separate\nVTools::Storage.connect_action
|
62
|
-
do\n # ... connect to the storage\nend\n```\n\n### Setup message (JSON)\n\n```\n{
|
63
|
-
\"action\" : \"convert|thumbs|info\", \"file\" : \"path/to/file\", \"setup\" : <
|
64
|
-
setup > }\n# setup can be:\n# -- \"predefined_set_id\"\n# -- { ffmpeg_options_hash
|
65
|
-
}\n# -- { \"set\": \"predefined_set_str\", ffmpeg_options_hash }\n```\n\n### User
|
66
|
-
friendly option names\n\n```\nconverter (ffmpeg)\n preserve_aspect (true or false)\n
|
67
|
-
\ extension (result file extension)\n width, height\n resolution\n duration\n\nthumbnailer
|
68
|
-
(ffmpegthumbnailer)\n thumb_count\n thumb_start_point (in percents)\n time (time
|
69
|
-
offset, alias for -t)\n quality (0 - 10)\n width\n```\n\n## Start\n\nTo
|
70
|
-
launch daemon is enough to require library with storage setup:\n (sudo) vtools
|
71
|
-
start -- -r library\n\n## Options\n\n### Daemon options are\n start\n stop\n restart\n\n###
|
72
|
-
Application options are:\n -c or --config-file - load config from file\n -r or
|
73
|
-
--require - load ruby library file (can be used more than once)\n\n### To see
|
74
|
-
complete options list use\n vtools --help\n\n### Using logger\n\nBy default the
|
75
|
-
`logger` gem is used. But there is possibility to set custom logger, that is compatible
|
76
|
-
with the default logger.\n\n``` ruby\nVTools.logger = CustomLoger.new($stdout)\n```\n\n###
|
77
|
-
Additioinal methods\n\nPath generator is used by the thumnailer, converter or both
|
78
|
-
to generate necessary dir tree logic for the media.\nIt accepts file name and should
|
79
|
-
return relative path (excluding file name itself)\n\n``` ruby\n# path generator
|
80
|
-
(used to )\nVTools.path_generator do |file_name|\n # ..\nend\n\n```\n\n**Network
|
81
|
-
calls** (TCP GET request, that will return message body content, ignoring response
|
82
|
-
headers)\n\n``` ruby\n\n# http calls\nVTools.network_call \"site.com/some/uri\"\nVTools.network_call
|
83
|
-
\"www.site.com\"\nVTools.network_call \"http://www.site.com\"\n```\n"
|
63
|
+
version_requirements: *id003
|
64
|
+
description: Daemon tools to operate the video (get info, encode & generate thumbnails).
|
84
65
|
email: v.tofir@gmail.com
|
85
|
-
executables:
|
66
|
+
executables:
|
86
67
|
- vtools
|
87
|
-
extensions:
|
68
|
+
extensions:
|
88
69
|
- extconf.rb
|
89
70
|
extra_rdoc_files: []
|
90
|
-
|
71
|
+
|
72
|
+
files:
|
91
73
|
- bin/vtools
|
92
74
|
- README.md
|
93
75
|
- Rakefile
|
@@ -100,7 +82,6 @@ files:
|
|
100
82
|
- lib/vtools/errors.rb
|
101
83
|
- lib/vtools/job.rb
|
102
84
|
- lib/vtools/convert_options.rb
|
103
|
-
- lib/vtools/version.rb~
|
104
85
|
- lib/vtools/thumbnailer.rb
|
105
86
|
- lib/vtools/shared_methods.rb
|
106
87
|
- lib/vtools/handler.rb
|
@@ -136,23 +117,32 @@ files:
|
|
136
117
|
- extconf.rb
|
137
118
|
homepage: http://tofir.comuv.com
|
138
119
|
licenses: []
|
120
|
+
|
139
121
|
post_install_message:
|
140
122
|
rdoc_options: []
|
141
|
-
|
123
|
+
|
124
|
+
require_paths:
|
142
125
|
- lib
|
143
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
127
|
none: false
|
145
|
-
requirements:
|
146
|
-
- -
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
|
149
|
-
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 29
|
132
|
+
segments:
|
133
|
+
- 1
|
134
|
+
- 9
|
135
|
+
version: "1.9"
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
137
|
none: false
|
151
|
-
requirements:
|
152
|
-
- -
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
|
155
|
-
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
hash: 3
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
version: "0"
|
145
|
+
requirements:
|
156
146
|
- ffmpeg v >= 1.8
|
157
147
|
- ffmpegthumbnailer v >= 2
|
158
148
|
- gem Daemons v >= 1.1.4
|
@@ -161,7 +151,7 @@ rubygems_version: 1.8.10
|
|
161
151
|
signing_key:
|
162
152
|
specification_version: 3
|
163
153
|
summary: Daemon tools to operate the video (get info, encode & generate thumbnails).
|
164
|
-
test_files:
|
154
|
+
test_files:
|
165
155
|
- spec/job_spec.rb
|
166
156
|
- spec/convert_options_spec.rb
|
167
157
|
- spec/config_spec.rb
|
data/lib/vtools/version.rb~
DELETED