media-preset 0.0.1
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/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +24 -0
- data/lib/media/preset.rb +95 -0
- data/lib/media/preset/android.rb +85 -0
- data/lib/media/preset/apple.rb +65 -0
- data/lib/media/preset/h264.rb +51 -0
- data/lib/media/preset/kindle.rb +50 -0
- data/lib/media/preset/mp3.rb +33 -0
- data/lib/media/preset/mp4.rb +43 -0
- data/lib/media/preset/playstation.rb +48 -0
- data/lib/media/preset/prores.rb +50 -0
- data/lib/media/preset/theora.rb +38 -0
- data/lib/media/preset/version.rb +5 -0
- data/lib/media/preset/vorbis.rb +36 -0
- data/lib/media/preset/webm.rb +63 -0
- data/media-preset.gemspec +22 -0
- data/test/helper.rb +4 -0
- metadata +139 -0
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jamie Hodge
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Media Preset
|
2
|
+
|
3
|
+
Media conversion presets, derived from the [Miro Conversion Matrix](https://develop.participatoryculture.org/index.php/ConversionMatrix)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'media-preset'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install media-preset
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
List presets:
|
22
|
+
|
23
|
+
Media::Preset.all
|
24
|
+
|
25
|
+
Use a preset:
|
26
|
+
|
27
|
+
Media::Preset.android(
|
28
|
+
:desire,
|
29
|
+
input: '/path/to/input.mov',
|
30
|
+
output: '/path/to/output.mov'
|
31
|
+
).call {|progress| p progress.to_f }
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Bundler.setup :default, :development
|
7
|
+
rescue Bundler::BundlerError => error
|
8
|
+
$stderr.puts error.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit error.status_code
|
11
|
+
end
|
12
|
+
|
13
|
+
Bundler::GemHelper.install_tasks
|
14
|
+
|
15
|
+
desc 'Run unit tests'
|
16
|
+
Rake::TestTask.new do |config|
|
17
|
+
config.libs << 'lib' << 'test'
|
18
|
+
config.pattern = 'test/**/test_*'
|
19
|
+
config.verbose = true
|
20
|
+
config.warning = true
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'Run tests'
|
24
|
+
task default: :test
|
data/lib/media/preset.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'media'
|
2
|
+
|
3
|
+
require_relative 'preset/version'
|
4
|
+
|
5
|
+
require_relative 'preset/android'
|
6
|
+
require_relative 'preset/apple'
|
7
|
+
require_relative 'preset/h264'
|
8
|
+
require_relative 'preset/kindle'
|
9
|
+
require_relative 'preset/mp3'
|
10
|
+
require_relative 'preset/mp4'
|
11
|
+
require_relative 'preset/playstation'
|
12
|
+
require_relative 'preset/prores'
|
13
|
+
require_relative 'preset/theora'
|
14
|
+
require_relative 'preset/vorbis'
|
15
|
+
require_relative 'preset/webm'
|
16
|
+
|
17
|
+
module Media
|
18
|
+
module Preset
|
19
|
+
extend self
|
20
|
+
|
21
|
+
def all
|
22
|
+
{
|
23
|
+
android: Android.presets.keys,
|
24
|
+
apple: Apple.presets.keys,
|
25
|
+
h264: H264.presets.keys,
|
26
|
+
webm: WebM.presets.keys,
|
27
|
+
prores: ProRes.presets.keys,
|
28
|
+
kindle: Kindle.presets.keys,
|
29
|
+
playstation: Playstation.presets.keys,
|
30
|
+
mp4: nil,
|
31
|
+
mp3: nil,
|
32
|
+
theora: nil,
|
33
|
+
vorbis: nil
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def android(preset, args={})
|
38
|
+
raise 'invalid preset' unless Android.presets.include?(preset)
|
39
|
+
|
40
|
+
Android::Base.new(args.merge(Android.presets[preset]))
|
41
|
+
end
|
42
|
+
|
43
|
+
def apple(preset, args={})
|
44
|
+
raise 'invalid preset' unless Apple.presets.include?(preset)
|
45
|
+
|
46
|
+
Apple::Base.new(args.merge(Apple.presets[preset]))
|
47
|
+
end
|
48
|
+
|
49
|
+
def h264(preset, args={})
|
50
|
+
raise 'invalid preset' unless H264.presets.include?(preset)
|
51
|
+
|
52
|
+
H264::Base.new(args.merge(H264.presets[preset]))
|
53
|
+
end
|
54
|
+
|
55
|
+
def webm(preset, args={})
|
56
|
+
raise 'invalid preset' unless WebM.presets.include?(preset)
|
57
|
+
|
58
|
+
WebM::Base.new(args.merge(WebM.presets[preset]))
|
59
|
+
end
|
60
|
+
|
61
|
+
def prores(preset, args={})
|
62
|
+
raise 'invalid preset' unless ProRes.presets.include?(preset)
|
63
|
+
|
64
|
+
ProRes::Base.new(args.merge(ProRes.presets[preset]))
|
65
|
+
end
|
66
|
+
|
67
|
+
def kindle(preset, args={})
|
68
|
+
raise 'invalid preset' unless Kindle.presets.include?(preset)
|
69
|
+
|
70
|
+
Kindle::Base.new(args.merge(Kindle.presets[preset]))
|
71
|
+
end
|
72
|
+
|
73
|
+
def playstation(preset, args={})
|
74
|
+
raise 'invalid preset' unless Playstation.presets.include?(preset)
|
75
|
+
|
76
|
+
Playstation::Base.new(args.merge(Playstation.presets[preset]))
|
77
|
+
end
|
78
|
+
|
79
|
+
def mp4(args={})
|
80
|
+
MP4::Base.new(args)
|
81
|
+
end
|
82
|
+
|
83
|
+
def mp3(args={})
|
84
|
+
MP3::Base.new(args)
|
85
|
+
end
|
86
|
+
|
87
|
+
def theora(args={})
|
88
|
+
Theora::Base.new(args)
|
89
|
+
end
|
90
|
+
|
91
|
+
def vorbis(args={})
|
92
|
+
Vorbis::Base.new(args)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module Android
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def presets
|
7
|
+
{
|
8
|
+
galaxy_y: {height: 240, width: 320},
|
9
|
+
galaxy_mini: {height: 240, width: 320},
|
10
|
+
wildfire: {height: 240, width: 320},
|
11
|
+
galaxy_ace: {height: 320, width: 480},
|
12
|
+
admire: {height: 320, width: 480},
|
13
|
+
droid_charge: {height: 480, width: 800},
|
14
|
+
galaxy_s: {height: 480, width: 800},
|
15
|
+
galaxy_s_ii: {height: 480, width: 800},
|
16
|
+
galaxy_s_plus: {height: 480, width: 800},
|
17
|
+
epic_touch_4g: {height: 480, width: 800},
|
18
|
+
desire: {height: 480, width: 800},
|
19
|
+
droid_incredible: {height: 480, width: 800},
|
20
|
+
thunderbolt: {height: 480, width: 800},
|
21
|
+
evo_4g: {height: 480, width: 800},
|
22
|
+
zio: {height: 480, width: 800},
|
23
|
+
galaxy_s_iii: {height: 720, width: 1280},
|
24
|
+
rezound: {height: 720, width: 1280},
|
25
|
+
one_x: {height: 720, width: 1280},
|
26
|
+
galaxy_tab: {height: 600, width: 1024},
|
27
|
+
galaxy_tab_10_1: {height: 800, width: 1280},
|
28
|
+
galaxy_note: {height: 800, width: 1280},
|
29
|
+
infuse_4g: {height: 800, width: 1280},
|
30
|
+
galaxy_note_ii: {height: 1080, width: 1920},
|
31
|
+
sensation: {height: 540, width: 960},
|
32
|
+
droid_x: {height: 854, width: 480},
|
33
|
+
droid_x2: {height: 1280, width: 720},
|
34
|
+
razr: {height: 960, width: 540},
|
35
|
+
xoom: {height: 1280, width: 800},
|
36
|
+
small: {height: 480, width: 320},
|
37
|
+
normal: {height: 800, width: 480},
|
38
|
+
large_720p: {height: 1280, width: 720},
|
39
|
+
large_1080p: {height: 1920, width: 1080}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
class Base
|
44
|
+
def initialize(args)
|
45
|
+
@width = args.fetch(:width) {raise 'width required'}
|
46
|
+
@height = args.fetch(:height) {raise 'height required'}
|
47
|
+
|
48
|
+
@input = args.fetch(:input) {raise 'input required'}
|
49
|
+
@output = args.fetch(:output) {raise 'output required'}
|
50
|
+
end
|
51
|
+
|
52
|
+
def call(&block)
|
53
|
+
conversion.call(&block)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def conversion
|
59
|
+
Media.convert do |c|
|
60
|
+
c.options y: true
|
61
|
+
|
62
|
+
c.input @input
|
63
|
+
|
64
|
+
c.output @output do |o|
|
65
|
+
o.options(
|
66
|
+
acodec: 'aac',
|
67
|
+
ab: '160k',
|
68
|
+
strict: 'experimental',
|
69
|
+
s: Media.size(width: @width, height: @height),
|
70
|
+
vcodec: 'libx264',
|
71
|
+
preset: 'slow',
|
72
|
+
'profile:v' => 'baseline',
|
73
|
+
level: 30,
|
74
|
+
maxrate: 10000000,
|
75
|
+
bufsize: 10000000,
|
76
|
+
f: 'mp4',
|
77
|
+
threads: 0
|
78
|
+
)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module Apple
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def presets
|
7
|
+
{
|
8
|
+
ipod: {height: 320, width: 480},
|
9
|
+
ipod_touch: {height: 480, width: 640},
|
10
|
+
iphone: {height: 480, width: 640},
|
11
|
+
ipod_touch_4: {height: 640, width: 960},
|
12
|
+
iphone_4: {height: 640, width: 960},
|
13
|
+
iphone_5: {height: 1080, width: 1920},
|
14
|
+
ipad_3: {height: 1080, width: 1920},
|
15
|
+
ipad: {height: 1024, height: 768},
|
16
|
+
apple_universal: {height: 720, width: 1280},
|
17
|
+
apple_tv: {height: 720, width: 1280}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
class Base
|
22
|
+
def initialize(args)
|
23
|
+
@width = args.fetch(:width) {raise 'width required'}
|
24
|
+
@height = args.fetch(:height) {raise 'height required'}
|
25
|
+
|
26
|
+
@input = args.fetch(:input) {raise 'input required'}
|
27
|
+
@output = args.fetch(:output) {raise 'output required'}
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(&block)
|
31
|
+
conversion.call(&block)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def conversion
|
37
|
+
Media.convert do |c|
|
38
|
+
c.options y: true
|
39
|
+
|
40
|
+
c.input @input
|
41
|
+
|
42
|
+
c.output @output do |o|
|
43
|
+
o.options(
|
44
|
+
acodec: 'aac',
|
45
|
+
ac: 2,
|
46
|
+
strict: 'experimental',
|
47
|
+
ab: '160k',
|
48
|
+
s: Media.size(width: @width, height: @height),
|
49
|
+
vcodec: 'libx264',
|
50
|
+
preset: 'slow',
|
51
|
+
'profile:v' => 'baseline',
|
52
|
+
level: 30,
|
53
|
+
maxrate: 10000000,
|
54
|
+
bufsize: 10000000,
|
55
|
+
'b:v' => '1200k',
|
56
|
+
f: 'mp4',
|
57
|
+
threads: 0
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module H264
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def presets
|
7
|
+
{
|
8
|
+
hd: {height: 720, width: 1280},
|
9
|
+
sd: {height: 480, width: 640}
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
class Base
|
14
|
+
def initialize(args)
|
15
|
+
@width = args.fetch(:width) {raise 'width required'}
|
16
|
+
@height = args.fetch(:height) {raise 'height required'}
|
17
|
+
|
18
|
+
@input = args.fetch(:input) {raise 'input required'}
|
19
|
+
@output = args.fetch(:output) {raise 'output required'}
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(&block)
|
23
|
+
conversion.call(&block)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def conversion
|
29
|
+
Media.convert do |c|
|
30
|
+
c.options y: true
|
31
|
+
|
32
|
+
c.input @input
|
33
|
+
|
34
|
+
c.output @output do |o|
|
35
|
+
o.options(
|
36
|
+
s: Media.size(width: @width, height: @height),
|
37
|
+
vcodec: 'libx264',
|
38
|
+
strict: 'experimental',
|
39
|
+
preset: 'slow',
|
40
|
+
crf: 24,
|
41
|
+
acodec: 'aac',
|
42
|
+
ab: '96k',
|
43
|
+
ar: 44100
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module Kindle
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def presets
|
7
|
+
{
|
8
|
+
fire: {height: 600, width: 1024}
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
class Base
|
13
|
+
def initialize(args)
|
14
|
+
@width = args.fetch(:width) {raise 'width required'}
|
15
|
+
@height = args.fetch(:height) {raise 'height required'}
|
16
|
+
|
17
|
+
@input = args.fetch(:input) {raise 'input required'}
|
18
|
+
@output = args.fetch(:output) {raise 'output required'}
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(&block)
|
22
|
+
conversion.call(&block)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def conversion
|
28
|
+
Media.convert do |c|
|
29
|
+
c.options y: true
|
30
|
+
|
31
|
+
c.input @input
|
32
|
+
|
33
|
+
c.output @output do |o|
|
34
|
+
o.options(
|
35
|
+
s: Media.size(width: @width, height: @height),
|
36
|
+
acodec: 'aac',
|
37
|
+
ab: '96k',
|
38
|
+
vcodec: 'libx264',
|
39
|
+
vpre: 'slow',
|
40
|
+
f: 'mp4',
|
41
|
+
crf: 22,
|
42
|
+
strict: 'experimental'
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module MP3
|
4
|
+
|
5
|
+
class Base
|
6
|
+
def initialize(args)
|
7
|
+
@input = args.fetch(:input) {raise 'input required'}
|
8
|
+
@output = args.fetch(:output) {raise 'output required'}
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(&block)
|
12
|
+
conversion.call(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def conversion
|
18
|
+
Media.convert do |c|
|
19
|
+
c.options y: true
|
20
|
+
|
21
|
+
c.input @input
|
22
|
+
|
23
|
+
c.output @output do |o|
|
24
|
+
o.options(
|
25
|
+
f: 'mp3'
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module MP4
|
4
|
+
|
5
|
+
class Base
|
6
|
+
def initialize(args)
|
7
|
+
@width = args.fetch(:width) {raise 'width required'}
|
8
|
+
@height = args.fetch(:height) {raise 'height required'}
|
9
|
+
|
10
|
+
@input = args.fetch(:input) {raise 'input required'}
|
11
|
+
@output = args.fetch(:output) {raise 'output required'}
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(&block)
|
15
|
+
conversion.call(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def conversion
|
21
|
+
Media.convert do |c|
|
22
|
+
c.options y: true
|
23
|
+
|
24
|
+
c.input @input
|
25
|
+
|
26
|
+
c.output @output do |o|
|
27
|
+
o.options(
|
28
|
+
acodec: 'aac',
|
29
|
+
strict: 'experimental',
|
30
|
+
ab: '96k',
|
31
|
+
s: Media.size(width: @width, height: @height),
|
32
|
+
vcodec: 'libx264',
|
33
|
+
preset: 'slow',
|
34
|
+
f: 'mp4',
|
35
|
+
crf: 22
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module Playstation
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def presets
|
7
|
+
{
|
8
|
+
psp: {height: 240, width: 320}
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
class Base
|
13
|
+
def initialize(args)
|
14
|
+
@width = args.fetch(:width) {raise 'width required'}
|
15
|
+
@height = args.fetch(:height) {raise 'height required'}
|
16
|
+
|
17
|
+
@input = args.fetch(:input) {raise 'input required'}
|
18
|
+
@output = args.fetch(:output) {raise 'output required'}
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(&block)
|
22
|
+
conversion.call(&block)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def conversion
|
28
|
+
Media.convert do |c|
|
29
|
+
c.options y: true
|
30
|
+
|
31
|
+
c.input @input
|
32
|
+
|
33
|
+
c.output @output do |o|
|
34
|
+
o.options(
|
35
|
+
s: Media.size(width: @width, height: @height),
|
36
|
+
b: 512000,
|
37
|
+
ar: 24000,
|
38
|
+
ab: 64000,
|
39
|
+
f: 'psp',
|
40
|
+
r: 29.97
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module ProRes
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def presets
|
7
|
+
{
|
8
|
+
normal_1080p: {height: 1080, width: 1920, profile: 2},
|
9
|
+
normal_720p: {height: 720, width: 1280, profile: 2}
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
class Base
|
14
|
+
def initialize(args)
|
15
|
+
@width = args.fetch(:width) {raise 'width required'}
|
16
|
+
@height = args.fetch(:height) {raise 'height required'}
|
17
|
+
|
18
|
+
@profile = args.fetch(:profile) {raise 'profile required'}
|
19
|
+
|
20
|
+
@input = args.fetch(:input) {raise 'input required'}
|
21
|
+
@output = args.fetch(:output) {raise 'output required'}
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(&block)
|
25
|
+
conversion.call(&block)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def conversion
|
31
|
+
Media.convert do |c|
|
32
|
+
c.options y: true
|
33
|
+
|
34
|
+
c.input @input
|
35
|
+
|
36
|
+
c.output @output do |o|
|
37
|
+
o.options(
|
38
|
+
s: Media.size(width: @width, height: @height),
|
39
|
+
vcodec: 'prores',
|
40
|
+
profile: @profile,
|
41
|
+
acodec: 'pcm_s16be',
|
42
|
+
ar: 48000
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module Theora
|
4
|
+
|
5
|
+
class Base
|
6
|
+
def initialize(args)
|
7
|
+
@width = args.fetch(:width) {raise 'width required'}
|
8
|
+
@height = args.fetch(:height) {raise 'height required'}
|
9
|
+
|
10
|
+
@input = args.fetch(:input) {raise 'input required'}
|
11
|
+
@output = args.fetch(:output) {raise 'output required'}
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(&block)
|
15
|
+
conversion.call(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def conversion
|
21
|
+
Media.convert do |c|
|
22
|
+
c.options y: true
|
23
|
+
|
24
|
+
c.input @input
|
25
|
+
|
26
|
+
c.output @output do |o|
|
27
|
+
o.options(
|
28
|
+
f: 'ogg',
|
29
|
+
acodec: 'libvorbis',
|
30
|
+
aq: 60
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module Vorbis
|
4
|
+
|
5
|
+
class Base
|
6
|
+
def initialize(args)
|
7
|
+
@input = args.fetch(:input) {raise 'input required'}
|
8
|
+
@output = args.fetch(:output) {raise 'output required'}
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(&block)
|
12
|
+
conversion.call(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def conversion
|
18
|
+
Media.convert do |c|
|
19
|
+
c.options y: true
|
20
|
+
|
21
|
+
c.input @input
|
22
|
+
|
23
|
+
c.output @output do |o|
|
24
|
+
o.options(
|
25
|
+
f: 'ogg',
|
26
|
+
vn: true,
|
27
|
+
acodec: 'libvorbis',
|
28
|
+
aq: 60
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Media
|
2
|
+
module Preset
|
3
|
+
module WebM
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def presets
|
7
|
+
{
|
8
|
+
hd: {height: 720, width: 1280, qmax: 51, qmin: 11, slices: 4, video_bitrate: '2M'},
|
9
|
+
sd: {height: 480, width: 640, qmax: 63, qmin: 0, slices: 1, video_bitrate: '768K'}
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
class Base
|
14
|
+
def initialize(args)
|
15
|
+
@width = args.fetch(:width) {raise 'width required'}
|
16
|
+
@height = args.fetch(:height) {raise 'height required'}
|
17
|
+
|
18
|
+
@video_bitrate = args.fetch(:video_bitrate) {raise 'video_bitrate required'}
|
19
|
+
@qmax = args.fetch(:qmax) {raise 'qmax required'}
|
20
|
+
@qmin = args.fetch(:qmin) {raise 'qmin required'}
|
21
|
+
@slices = args.fetch(:slices) {raise 'slices required'}
|
22
|
+
|
23
|
+
@input = args.fetch(:input) {raise 'input required'}
|
24
|
+
@output = args.fetch(:output) {raise 'output required'}
|
25
|
+
end
|
26
|
+
|
27
|
+
def call(&block)
|
28
|
+
conversion.call(&block)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def conversion
|
34
|
+
Media.convert do |c|
|
35
|
+
c.options y: true
|
36
|
+
|
37
|
+
c.input @input
|
38
|
+
|
39
|
+
c.output @output do |o|
|
40
|
+
o.options(
|
41
|
+
s: Media.size(width: @width, height: @height),
|
42
|
+
vcodec: 'libvpx',
|
43
|
+
g: 120,
|
44
|
+
'lag-in-frames' => 16,
|
45
|
+
deadline: 'good',
|
46
|
+
'cpu-used' => 0,
|
47
|
+
vprofile: 0,
|
48
|
+
qmax: @qmax,
|
49
|
+
qmin: @qmin,
|
50
|
+
slices: @slices,
|
51
|
+
'b:v' => @video_bitrate,
|
52
|
+
acodec: 'libvorbis',
|
53
|
+
ab: '112k',
|
54
|
+
ar: 44100,
|
55
|
+
f: 'webm'
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/lib/media/preset/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'media-preset'
|
6
|
+
gem.version = Media::Preset::VERSION
|
7
|
+
gem.authors = ['Jamie Hodge']
|
8
|
+
gem.email = ['jamiehodge@me.com']
|
9
|
+
gem.summary = 'Media presets'
|
10
|
+
gem.description = gem.summary
|
11
|
+
gem.homepage = 'https://github.com/jamiehodge/media-preset'
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split($/)
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_dependency('media', "~> 0.0.4")
|
19
|
+
|
20
|
+
gem.add_development_dependency('rake')
|
21
|
+
gem.add_development_dependency('minitest')
|
22
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: media-preset
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jamie Hodge
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
prerelease: false
|
16
|
+
type: :runtime
|
17
|
+
name: media
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.0.4
|
23
|
+
none: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 0.0.4
|
29
|
+
none: false
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
prerelease: false
|
32
|
+
type: :development
|
33
|
+
name: rake
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
none: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
none: false
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
prerelease: false
|
48
|
+
type: :development
|
49
|
+
name: minitest
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
none: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
none: false
|
62
|
+
description: Media presets
|
63
|
+
email:
|
64
|
+
- jamiehodge@me.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- !binary |-
|
70
|
+
R2VtZmlsZQ==
|
71
|
+
- !binary |-
|
72
|
+
TElDRU5TRS50eHQ=
|
73
|
+
- !binary |-
|
74
|
+
UkVBRE1FLm1k
|
75
|
+
- !binary |-
|
76
|
+
UmFrZWZpbGU=
|
77
|
+
- !binary |-
|
78
|
+
bGliL21lZGlhL3ByZXNldC5yYg==
|
79
|
+
- !binary |-
|
80
|
+
bGliL21lZGlhL3ByZXNldC9hbmRyb2lkLnJi
|
81
|
+
- !binary |-
|
82
|
+
bGliL21lZGlhL3ByZXNldC9hcHBsZS5yYg==
|
83
|
+
- !binary |-
|
84
|
+
bGliL21lZGlhL3ByZXNldC9oMjY0LnJi
|
85
|
+
- !binary |-
|
86
|
+
bGliL21lZGlhL3ByZXNldC9raW5kbGUucmI=
|
87
|
+
- !binary |-
|
88
|
+
bGliL21lZGlhL3ByZXNldC9tcDMucmI=
|
89
|
+
- !binary |-
|
90
|
+
bGliL21lZGlhL3ByZXNldC9tcDQucmI=
|
91
|
+
- !binary |-
|
92
|
+
bGliL21lZGlhL3ByZXNldC9wbGF5c3RhdGlvbi5yYg==
|
93
|
+
- !binary |-
|
94
|
+
bGliL21lZGlhL3ByZXNldC9wcm9yZXMucmI=
|
95
|
+
- !binary |-
|
96
|
+
bGliL21lZGlhL3ByZXNldC90aGVvcmEucmI=
|
97
|
+
- !binary |-
|
98
|
+
bGliL21lZGlhL3ByZXNldC92ZXJzaW9uLnJi
|
99
|
+
- !binary |-
|
100
|
+
bGliL21lZGlhL3ByZXNldC92b3JiaXMucmI=
|
101
|
+
- !binary |-
|
102
|
+
bGliL21lZGlhL3ByZXNldC93ZWJtLnJi
|
103
|
+
- !binary |-
|
104
|
+
bWVkaWEtcHJlc2V0LmdlbXNwZWM=
|
105
|
+
- !binary |-
|
106
|
+
dGVzdC9oZWxwZXIucmI=
|
107
|
+
homepage: https://github.com/jamiehodge/media-preset
|
108
|
+
licenses: []
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
hash: 2002549777813010636
|
120
|
+
version: '0'
|
121
|
+
none: false
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
hash: 2002549777813010636
|
129
|
+
version: '0'
|
130
|
+
none: false
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 1.8.24
|
134
|
+
signing_key:
|
135
|
+
specification_version: 3
|
136
|
+
summary: Media presets
|
137
|
+
test_files:
|
138
|
+
- !binary |-
|
139
|
+
dGVzdC9oZWxwZXIucmI=
|