media 0.0.4 → 0.0.6
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/Gemfile +1 -1
- data/LICENSE.txt +2 -2
- data/README.md +19 -8
- data/lib/media.rb +4 -0
- data/lib/media/container.rb +21 -8
- data/lib/media/filter.rb +19 -5
- data/lib/media/version.rb +1 -1
- data/test/media/test_filter.rb +3 -2
- metadata +63 -123
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2fb70c328dee96f418950ed12a3d85b60ee75aee
|
4
|
+
data.tar.gz: 83bea2146bbcea48d42fbfb354d48ebc56a9ae89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7a73aff5350a8ca3bdb8fc0191f98c45115bbce8b850d48f78655b4afc3ae767afb67013a5354da6240034a8936fe61997eeb8202efbc9e96f283daba8f9ece
|
7
|
+
data.tar.gz: dad2c218fb341c24cc3a9bd778c06fb6500ce558f666e93dfb21dd56ec17a37d454d7941ba485c338396fb76fa84faa9e3bdf99ecda2fd89ba309ece6df5feab
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2013
|
1
|
+
Copyright (c) 2013 Copenhagen University
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ An `ffmpeg` or `avconv` wrapper
|
|
6
6
|
|
7
7
|
Install ffmpeg:
|
8
8
|
|
9
|
-
brew install ffmpeg
|
9
|
+
brew install ffmpeg --with-tools --with-libvpx --with-libvorbis --with-libtheora
|
10
10
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
@@ -22,26 +22,29 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
Convert:
|
26
|
+
|
25
27
|
conversion = Media.convert do
|
26
28
|
options y: true
|
27
29
|
|
30
|
+
# this example is slow, due to heavy network usage
|
28
31
|
input 'http://www.google.com/images/srpr/logo3w.png' do
|
29
32
|
options loop: 1, f: 'image2'
|
30
33
|
end
|
31
34
|
|
32
|
-
output '/path/to/
|
35
|
+
output '/path/to/example.webm' do
|
33
36
|
options vcodec: 'libvpx', acodec: 'libvorbis', t: 4
|
34
37
|
maps label('video'), label('audio')
|
35
38
|
graph do
|
36
39
|
chain do
|
37
40
|
filter 'negate'
|
38
|
-
filter 'hflip' do
|
39
|
-
outputs 'video'
|
41
|
+
filter 'hflip' do |f| # optional
|
42
|
+
f.outputs 'video'
|
40
43
|
end
|
41
44
|
end
|
42
45
|
chain do
|
43
46
|
filter 'aevalsrc' do
|
44
|
-
|
47
|
+
expressions 'sin(440*2*PI*t)'
|
45
48
|
outputs 'audio'
|
46
49
|
end
|
47
50
|
end
|
@@ -50,10 +53,18 @@ Or install it yourself as:
|
|
50
53
|
end
|
51
54
|
|
52
55
|
conversion.call {|progress| p progress}
|
56
|
+
|
57
|
+
Probe:
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
59
|
+
probe = Media.probe('/path/to/example.mov') do
|
60
|
+
options show_frames: true
|
61
|
+
end
|
62
|
+
|
63
|
+
probe.format
|
64
|
+
probe.streams
|
65
|
+
probe.streams('audio')
|
66
|
+
probe.frames # requires show_frames option
|
67
|
+
probe.metadata # => Hash
|
57
68
|
|
58
69
|
## Contributing
|
59
70
|
|
data/lib/media.rb
CHANGED
data/lib/media/container.rb
CHANGED
@@ -7,31 +7,44 @@ require_relative 'option'
|
|
7
7
|
module Media
|
8
8
|
class Container
|
9
9
|
|
10
|
-
attr_reader :url
|
10
|
+
attr_reader :url
|
11
11
|
|
12
|
-
def initialize(args)
|
13
|
-
@url = args.fetch(:url)
|
12
|
+
def initialize(args, &block)
|
13
|
+
@url = args.fetch(:url) { raise ':url required'}
|
14
14
|
@probe = args.fetch(:probe, Command::Probe)
|
15
|
-
@options = args.fetch(:options, [])
|
15
|
+
@options = args.fetch(:options, [])
|
16
|
+
|
17
|
+
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
18
|
+
end
|
19
|
+
|
20
|
+
def options(value=nil)
|
21
|
+
return @options + required_options unless value
|
22
|
+
|
23
|
+
@options = value.map {|k,v| Option.new(key: k, value: v)}
|
16
24
|
end
|
25
|
+
alias_method :options=, :options
|
17
26
|
|
18
27
|
def format
|
19
28
|
OpenStruct.new(metadata['format'])
|
20
29
|
end
|
21
30
|
|
22
|
-
def streams(
|
23
|
-
type = args.fetch(:type, /.*/)
|
24
|
-
|
31
|
+
def streams(type=/.*/)
|
25
32
|
metadata['streams'].select {|s| s['codec_type'].match(type)}.
|
26
33
|
map {|s| OpenStruct.new(s)}
|
27
34
|
end
|
28
35
|
|
29
|
-
|
36
|
+
def frames
|
37
|
+
warn 'show_frames option required' unless metadata['frames']
|
38
|
+
|
39
|
+
Array(metadata['frames']).map {|s| OpenStruct.new(s)}
|
40
|
+
end
|
30
41
|
|
31
42
|
def metadata
|
32
43
|
@metadata ||= JSON.parse(probe.out)
|
33
44
|
end
|
34
45
|
|
46
|
+
private
|
47
|
+
|
35
48
|
def probe
|
36
49
|
@probe.new(input: @url, options: options).call
|
37
50
|
end
|
data/lib/media/filter.rb
CHANGED
@@ -8,10 +8,11 @@ module Media
|
|
8
8
|
attr_reader :name
|
9
9
|
|
10
10
|
def initialize(args, &block)
|
11
|
-
@name
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
11
|
+
@name = args.fetch(:name)
|
12
|
+
@expressions = Array args.fetch(:expressions, [])
|
13
|
+
@arguments = Array args.fetch(:arguments, [])
|
14
|
+
@inputs = Array args.fetch(:inputs, [])
|
15
|
+
@outputs = Array args.fetch(:outputs, [])
|
15
16
|
|
16
17
|
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
17
18
|
end
|
@@ -41,10 +42,23 @@ module Media
|
|
41
42
|
end
|
42
43
|
alias_method :arguments=, :arguments
|
43
44
|
|
45
|
+
def expressions(*value)
|
46
|
+
return @expressions if value.empty?
|
47
|
+
|
48
|
+
@expressions = value
|
49
|
+
end
|
50
|
+
alias_method :expressions=, :expressions
|
51
|
+
|
44
52
|
private
|
45
53
|
|
46
54
|
def filter
|
47
|
-
[
|
55
|
+
[
|
56
|
+
name,
|
57
|
+
[
|
58
|
+
expressions.join(':'),
|
59
|
+
arguments.join(':')
|
60
|
+
].reject(&:empty?).join('::')
|
61
|
+
].reject(&:empty?).join('=')
|
48
62
|
end
|
49
63
|
end
|
50
64
|
end
|
data/lib/media/version.rb
CHANGED
data/test/media/test_filter.rb
CHANGED
@@ -6,13 +6,14 @@ module Media
|
|
6
6
|
|
7
7
|
def test_to_s
|
8
8
|
filter = Filter.new(
|
9
|
-
name: 'name',
|
9
|
+
name: 'name',
|
10
|
+
expressions: 'expressions',
|
10
11
|
arguments: 'arguments',
|
11
12
|
inputs: 'inputs',
|
12
13
|
outputs: 'outputs'
|
13
14
|
)
|
14
15
|
|
15
|
-
assert_equal('inputs name=arguments outputs', filter.to_s)
|
16
|
+
assert_equal('inputs name=expressions::arguments outputs', filter.to_s)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
metadata
CHANGED
@@ -1,48 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: media
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.4
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jamie Hodge
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
prerelease: false
|
16
|
-
type: :development
|
17
14
|
name: rake
|
18
15
|
requirement: !ruby/object:Gem::Requirement
|
19
16
|
requirements:
|
20
|
-
- -
|
17
|
+
- - '>='
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '0'
|
23
|
-
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
requirements:
|
26
|
-
- -
|
24
|
+
- - '>='
|
27
25
|
- !ruby/object:Gem::Version
|
28
26
|
version: '0'
|
29
|
-
none: false
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
prerelease: false
|
32
|
-
type: :development
|
33
28
|
name: minitest
|
34
29
|
requirement: !ruby/object:Gem::Requirement
|
35
30
|
requirements:
|
36
|
-
- -
|
31
|
+
- - '>='
|
37
32
|
- !ruby/object:Gem::Version
|
38
33
|
version: '0'
|
39
|
-
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
requirements:
|
42
|
-
- -
|
38
|
+
- - '>='
|
43
39
|
- !ruby/object:Gem::Version
|
44
40
|
version: '0'
|
45
|
-
none: false
|
46
41
|
description: FFMPEG/AVConv wrapper
|
47
42
|
email:
|
48
43
|
- jamiehodge@me.com
|
@@ -50,130 +45,75 @@ executables: []
|
|
50
45
|
extensions: []
|
51
46
|
extra_rdoc_files: []
|
52
47
|
files:
|
53
|
-
-
|
54
|
-
|
55
|
-
-
|
56
|
-
|
57
|
-
-
|
58
|
-
|
59
|
-
-
|
60
|
-
|
61
|
-
-
|
62
|
-
|
63
|
-
-
|
64
|
-
|
65
|
-
-
|
66
|
-
|
67
|
-
-
|
68
|
-
|
69
|
-
-
|
70
|
-
|
71
|
-
-
|
72
|
-
|
73
|
-
-
|
74
|
-
|
75
|
-
-
|
76
|
-
|
77
|
-
-
|
78
|
-
|
79
|
-
-
|
80
|
-
|
81
|
-
-
|
82
|
-
|
83
|
-
-
|
84
|
-
|
85
|
-
-
|
86
|
-
|
87
|
-
-
|
88
|
-
|
89
|
-
- !binary |-
|
90
|
-
bGliL21lZGlhL2hlbHBlci9zaXplLnJi
|
91
|
-
- !binary |-
|
92
|
-
bGliL21lZGlhL2lucHV0LnJi
|
93
|
-
- !binary |-
|
94
|
-
bGliL21lZGlhL29wdGlvbi5yYg==
|
95
|
-
- !binary |-
|
96
|
-
bGliL21lZGlhL291dHB1dC5yYg==
|
97
|
-
- !binary |-
|
98
|
-
bGliL21lZGlhL3ZlcnNpb24ucmI=
|
99
|
-
- !binary |-
|
100
|
-
bWVkaWEuZ2Vtc3BlYw==
|
101
|
-
- !binary |-
|
102
|
-
dGVzdC9oZWxwZXIucmI=
|
103
|
-
- !binary |-
|
104
|
-
dGVzdC9tZWRpYS9jb21tYW5kL3Rlc3RfY29udmVydGVyLnJi
|
105
|
-
- !binary |-
|
106
|
-
dGVzdC9tZWRpYS9jb21tYW5kL3Rlc3RfcHJvYmUucmI=
|
107
|
-
- !binary |-
|
108
|
-
dGVzdC9tZWRpYS9jb21tYW5kL3Rlc3Rfc3Vic2hlbGwucmI=
|
109
|
-
- !binary |-
|
110
|
-
dGVzdC9tZWRpYS9maWx0ZXIvdGVzdF9hcmd1bWVudC5yYg==
|
111
|
-
- !binary |-
|
112
|
-
dGVzdC9tZWRpYS9maWx0ZXIvdGVzdF9jaGFpbi5yYg==
|
113
|
-
- !binary |-
|
114
|
-
dGVzdC9tZWRpYS9maWx0ZXIvdGVzdF9ncmFwaC5yYg==
|
115
|
-
- !binary |-
|
116
|
-
dGVzdC9tZWRpYS9oZWxwZXIvdGVzdF9sYWJlbC5yYg==
|
117
|
-
- !binary |-
|
118
|
-
dGVzdC9tZWRpYS90ZXN0X2ZpbHRlci5yYg==
|
119
|
-
- !binary |-
|
120
|
-
dGVzdC9tZWRpYS90ZXN0X2lucHV0LnJi
|
121
|
-
- !binary |-
|
122
|
-
dGVzdC9tZWRpYS90ZXN0X29wdGlvbi5yYg==
|
123
|
-
- !binary |-
|
124
|
-
dGVzdC9tZWRpYS90ZXN0X291dHB1dC5yYg==
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/media.rb
|
54
|
+
- lib/media/command.rb
|
55
|
+
- lib/media/command/converter.rb
|
56
|
+
- lib/media/command/probe.rb
|
57
|
+
- lib/media/command/progress.rb
|
58
|
+
- lib/media/command/subshell.rb
|
59
|
+
- lib/media/container.rb
|
60
|
+
- lib/media/filter.rb
|
61
|
+
- lib/media/filter/argument.rb
|
62
|
+
- lib/media/filter/chain.rb
|
63
|
+
- lib/media/filter/graph.rb
|
64
|
+
- lib/media/helper.rb
|
65
|
+
- lib/media/helper/label.rb
|
66
|
+
- lib/media/helper/size.rb
|
67
|
+
- lib/media/input.rb
|
68
|
+
- lib/media/option.rb
|
69
|
+
- lib/media/output.rb
|
70
|
+
- lib/media/version.rb
|
71
|
+
- media.gemspec
|
72
|
+
- test/helper.rb
|
73
|
+
- test/media/command/test_converter.rb
|
74
|
+
- test/media/command/test_probe.rb
|
75
|
+
- test/media/command/test_subshell.rb
|
76
|
+
- test/media/filter/test_argument.rb
|
77
|
+
- test/media/filter/test_chain.rb
|
78
|
+
- test/media/filter/test_graph.rb
|
79
|
+
- test/media/helper/test_label.rb
|
80
|
+
- test/media/test_filter.rb
|
81
|
+
- test/media/test_input.rb
|
82
|
+
- test/media/test_option.rb
|
83
|
+
- test/media/test_output.rb
|
125
84
|
homepage: https://github.com/jamiehodge/media
|
126
85
|
licenses: []
|
86
|
+
metadata: {}
|
127
87
|
post_install_message:
|
128
88
|
rdoc_options: []
|
129
89
|
require_paths:
|
130
90
|
- lib
|
131
91
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
92
|
requirements:
|
133
|
-
- -
|
93
|
+
- - '>='
|
134
94
|
- !ruby/object:Gem::Version
|
135
|
-
segments:
|
136
|
-
- 0
|
137
|
-
hash: 2002549777813010636
|
138
95
|
version: '0'
|
139
|
-
none: false
|
140
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
97
|
requirements:
|
142
|
-
- -
|
98
|
+
- - '>='
|
143
99
|
- !ruby/object:Gem::Version
|
144
|
-
segments:
|
145
|
-
- 0
|
146
|
-
hash: 2002549777813010636
|
147
100
|
version: '0'
|
148
|
-
none: false
|
149
101
|
requirements: []
|
150
102
|
rubyforge_project:
|
151
|
-
rubygems_version:
|
103
|
+
rubygems_version: 2.0.2
|
152
104
|
signing_key:
|
153
|
-
specification_version:
|
105
|
+
specification_version: 4
|
154
106
|
summary: FFMPEG/AVConv wrapper
|
155
107
|
test_files:
|
156
|
-
-
|
157
|
-
|
158
|
-
-
|
159
|
-
|
160
|
-
-
|
161
|
-
|
162
|
-
-
|
163
|
-
|
164
|
-
-
|
165
|
-
|
166
|
-
-
|
167
|
-
|
168
|
-
- !binary |-
|
169
|
-
dGVzdC9tZWRpYS9maWx0ZXIvdGVzdF9ncmFwaC5yYg==
|
170
|
-
- !binary |-
|
171
|
-
dGVzdC9tZWRpYS9oZWxwZXIvdGVzdF9sYWJlbC5yYg==
|
172
|
-
- !binary |-
|
173
|
-
dGVzdC9tZWRpYS90ZXN0X2ZpbHRlci5yYg==
|
174
|
-
- !binary |-
|
175
|
-
dGVzdC9tZWRpYS90ZXN0X2lucHV0LnJi
|
176
|
-
- !binary |-
|
177
|
-
dGVzdC9tZWRpYS90ZXN0X29wdGlvbi5yYg==
|
178
|
-
- !binary |-
|
179
|
-
dGVzdC9tZWRpYS90ZXN0X291dHB1dC5yYg==
|
108
|
+
- test/helper.rb
|
109
|
+
- test/media/command/test_converter.rb
|
110
|
+
- test/media/command/test_probe.rb
|
111
|
+
- test/media/command/test_subshell.rb
|
112
|
+
- test/media/filter/test_argument.rb
|
113
|
+
- test/media/filter/test_chain.rb
|
114
|
+
- test/media/filter/test_graph.rb
|
115
|
+
- test/media/helper/test_label.rb
|
116
|
+
- test/media/test_filter.rb
|
117
|
+
- test/media/test_input.rb
|
118
|
+
- test/media/test_option.rb
|
119
|
+
- test/media/test_output.rb
|