media-preset 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 CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  List presets:
22
22
 
23
- Media::Preset.all
23
+ Media::Preset.all # => {:android=>[:galaxy_y, :galaxy_mini, :wildfire, :galaxy_ace, :admire, :droid_charge, :galaxy_s, :galaxy_s_ii, :galaxy_s_plus, :epic_touch_4g, :desire, :droid_incredible, :thunderbolt, :evo_4g, :zio, :galaxy_s_iii, :rezound, :one_x, :galaxy_tab, :galaxy_tab_10_1, :galaxy_note, :infuse_4g, :galaxy_note_ii, :sensation, :droid_x, :droid_x2, :razr, :xoom, :small, :normal, :large_720p, :large_1080p], :apple=>[:ipod, :ipod_touch, :iphone, :ipod_touch_4, :iphone_4, :iphone_5, :ipad_3, :ipad, :apple_universal, :apple_tv], :h264=>[:hd, :sd], :webm=>[:hd, :sd], :prores=>[:normal_1080p, :normal_720p], :kindle=>[:fire], :playstation=>[:psp], :mp4=>nil, :mp3=>nil, :theora=>nil, :vorbis=>nil}
24
24
 
25
25
  Use a preset:
26
26
 
data/lib/media/preset.rb CHANGED
@@ -17,79 +17,82 @@ require_relative 'preset/webm'
17
17
  module Media
18
18
  module Preset
19
19
  extend self
20
+ include Enumerable
20
21
 
21
22
  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
- }
23
+ [Android, Apple, H264, WebM, ProRes, Kindle, Playstation, MP4, MP3, Theora, Vorbis].each_with_object([]) do |group, obj|
24
+ group.presets.keys.map {|preset| obj << group.new(preset) }
25
+ end
35
26
  end
36
27
 
37
- def android(preset, args={})
38
- raise 'invalid preset' unless Android.presets.include?(preset)
28
+ def each &block
29
+ all.each &block
30
+ end
31
+
32
+ def android(preset)
33
+ raise 'invalid preset' unless Android.preset? preset
39
34
 
40
- Android::Base.new(args.merge(Android.presets[preset]))
35
+ Android.new(preset)
41
36
  end
42
37
 
43
- def apple(preset, args={})
44
- raise 'invalid preset' unless Apple.presets.include?(preset)
38
+ def apple(preset)
39
+ raise 'invalid preset' unless Apple.preset? preset
45
40
 
46
- Apple::Base.new(args.merge(Apple.presets[preset]))
41
+ Apple.new(preset)
47
42
  end
48
43
 
49
- def h264(preset, args={})
50
- raise 'invalid preset' unless H264.presets.include?(preset)
44
+ def h264(preset)
45
+ raise 'invalid preset' unless H264.preset? preset
51
46
 
52
- H264::Base.new(args.merge(H264.presets[preset]))
47
+ H264.new(preset)
53
48
  end
54
49
 
55
- def webm(preset, args={})
56
- raise 'invalid preset' unless WebM.presets.include?(preset)
50
+ def webm(preset)
51
+ raise 'invalid preset' unless WebM.preset? preset
57
52
 
58
- WebM::Base.new(args.merge(WebM.presets[preset]))
53
+ WebM.new(preset)
59
54
  end
60
55
 
61
- def prores(preset, args={})
62
- raise 'invalid preset' unless ProRes.presets.include?(preset)
63
-
64
- ProRes::Base.new(args.merge(ProRes.presets[preset]))
56
+ def prores(preset)
57
+ raise 'invalid preset' unless ProRes.preset? preset
58
+
59
+ ProRes.new(preset)
65
60
  end
66
61
 
67
- def kindle(preset, args={})
68
- raise 'invalid preset' unless Kindle.presets.include?(preset)
62
+ def kindle(preset)
63
+ raise 'invalid preset' unless Kindle.preset? preset
69
64
 
70
- Kindle::Base.new(args.merge(Kindle.presets[preset]))
65
+ Kindle.new(preset)
71
66
  end
72
67
 
73
- def playstation(preset, args={})
74
- raise 'invalid preset' unless Playstation.presets.include?(preset)
68
+ def playstation(preset)
69
+ raise 'invalid preset' unless Playstation.preset? preset
75
70
 
76
- Playstation::Base.new(args.merge(Playstation.presets[preset]))
71
+ Playstation.new(preset)
77
72
  end
78
73
 
79
- def mp4(args={})
80
- MP4::Base.new(args)
74
+ def mp4(preset=:default)
75
+ raise 'invalid preset' unless MP4.preset? preset
76
+
77
+ MP4.new(preset)
81
78
  end
82
79
 
83
- def mp3(args={})
84
- MP3::Base.new(args)
80
+ def mp3(preset=:default)
81
+ raise 'invalid preset' unless MP3.preset? preset
82
+
83
+ MP3.new(preset)
85
84
  end
86
85
 
87
- def theora(args={})
88
- Theora::Base.new(args)
86
+ def theora(preset=:default)
87
+ raise 'invalid preset' unless Theora.preset? preset
88
+
89
+ Theora.new(preset)
89
90
  end
90
91
 
91
- def vorbis(args={})
92
- Vorbis::Base.new(args)
92
+ def vorbis(preset=:default)
93
+ raise 'invalid preset' unless Vorbis.preset? preset
94
+
95
+ Vorbis.new(preset)
93
96
  end
94
97
  end
95
98
  end
@@ -1,9 +1,10 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module Android
4
- extend self
5
+ class Android < Base
5
6
 
6
- def presets
7
+ def self.presets
7
8
  {
8
9
  galaxy_y: {height: 240, width: 320},
9
10
  galaxy_mini: {height: 240, width: 320},
@@ -39,44 +40,34 @@ module Media
39
40
  large_1080p: {height: 1920, width: 1080}
40
41
  }
41
42
  end
43
+
44
+ private
42
45
 
43
- class Base
44
- def initialize(args)
45
- @width = args.fetch(:width) {raise 'width required'}
46
- @height = args.fetch(:height) {raise 'height required'}
46
+ def extension
47
+ 'mp4'
48
+ end
49
+
50
+ def conversion(input, output)
51
+ Media.convert do |c|
52
+ c.options y: true
47
53
 
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
54
+ c.input input
55
+
56
+ c.output output do |o|
57
+ o.options(
58
+ acodec: 'aac',
59
+ ab: '160k',
60
+ strict: 'experimental',
61
+ s: Media.size(width: preset.width, height: preset.height),
62
+ vcodec: 'libx264',
63
+ preset: 'slow',
64
+ 'profile:v' => 'baseline',
65
+ level: 30,
66
+ maxrate: 10000000,
67
+ bufsize: 10000000,
68
+ f: 'mp4',
69
+ threads: 0
70
+ )
80
71
  end
81
72
  end
82
73
  end
@@ -1,9 +1,10 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module Apple
4
- extend self
5
+ class Apple < Base
5
6
 
6
- def presets
7
+ def self.presets
7
8
  {
8
9
  ipod: {height: 320, width: 480},
9
10
  ipod_touch: {height: 480, width: 640},
@@ -17,46 +18,36 @@ module Media
17
18
  apple_tv: {height: 720, width: 1280}
18
19
  }
19
20
  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
21
 
34
- private
22
+ private
35
23
 
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
24
+ def extension
25
+ 'mov'
26
+ end
27
+
28
+ def conversion(input, output)
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
+ acodec: 'aac',
37
+ ac: 2,
38
+ strict: 'experimental',
39
+ ab: '160k',
40
+ s: Media.size(width: preset.width, height: preset.height),
41
+ vcodec: 'libx264',
42
+ preset: 'slow',
43
+ 'profile:v' => 'baseline',
44
+ level: 30,
45
+ maxrate: 10000000,
46
+ bufsize: 10000000,
47
+ 'b:v' => '1200k',
48
+ f: 'mp4',
49
+ threads: 0
50
+ )
60
51
  end
61
52
  end
62
53
  end
@@ -0,0 +1,42 @@
1
+ require 'ostruct'
2
+
3
+ module Media
4
+ module Preset
5
+ class Base
6
+
7
+ def self.presets
8
+ {}
9
+ end
10
+
11
+ def self.preset?(preset)
12
+ !!presets[preset]
13
+ end
14
+
15
+ def initialize preset
16
+ @preset = preset
17
+ end
18
+
19
+ def call input, output, &block
20
+ conversion(input, output).call &block
21
+ end
22
+
23
+ def to_s
24
+ [self.class.name.gsub(/^.*::/, ''), @preset, extension].map(&:downcase).join '.'
25
+ end
26
+
27
+ private
28
+
29
+ def preset
30
+ OpenStruct.new self.class.presets[@preset]
31
+ end
32
+
33
+ def extension
34
+ raise NotImplementedError
35
+ end
36
+
37
+ def conversion(input, output)
38
+ raise NotImplementedError
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,48 +1,39 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module H264
4
- extend self
5
+ class H264 < Base
5
6
 
6
- def presets
7
+ def self.presets
7
8
  {
8
9
  hd: {height: 720, width: 1280},
9
10
  sd: {height: 480, width: 640}
10
11
  }
11
12
  end
12
13
 
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
14
+ private
25
15
 
26
- private
16
+ def extension
17
+ 'mp4'
18
+ end
27
19
 
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
20
+ def conversion(input, output)
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
+ s: Media.size(width: preset.width, height: preset.height),
29
+ vcodec: 'libx264',
30
+ strict: 'experimental',
31
+ preset: 'slow',
32
+ crf: 24,
33
+ acodec: 'aac',
34
+ ab: '96k',
35
+ ar: 44100
36
+ )
46
37
  end
47
38
  end
48
39
  end
@@ -1,47 +1,38 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module Kindle
4
- extend self
5
+ class Kindle < Base
5
6
 
6
- def presets
7
+ def self.presets
7
8
  {
8
9
  fire: {height: 600, width: 1024}
9
10
  }
10
11
  end
11
12
 
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
13
+ private
24
14
 
25
- private
15
+ def extension
16
+ 'mp4'
17
+ end
26
18
 
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
19
+ def conversion(input, output)
20
+ Media.convert do |c|
21
+ c.options y: true
22
+
23
+ c.input input
24
+
25
+ c.output output do |o|
26
+ o.options(
27
+ s: Media.size(width: preset.width, height: preset.height),
28
+ acodec: 'aac',
29
+ ab: '96k',
30
+ vcodec: 'libx264',
31
+ vpre: 'slow',
32
+ f: 'mp4',
33
+ crf: 22,
34
+ strict: 'experimental'
35
+ )
45
36
  end
46
37
  end
47
38
  end
@@ -1,30 +1,31 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module MP3
5
+ class MP3 < Base
4
6
 
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
7
+ def self.presets
8
+ {
9
+ default: {}
10
+ }
11
+ end
10
12
 
11
- def call(&block)
12
- conversion.call(&block)
13
- end
13
+ private
14
14
 
15
- private
15
+ def extension
16
+ 'mp3'
17
+ end
16
18
 
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
19
+ def conversion(input, output)
20
+ Media.convert do |c|
21
+ c.options y: true
22
+
23
+ c.input input
24
+
25
+ c.output output do |o|
26
+ o.options(
27
+ f: 'mp3'
28
+ )
28
29
  end
29
30
  end
30
31
  end
@@ -1,40 +1,38 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module MP4
5
+ class MP4 < Base
4
6
 
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
7
+ def self.presets
8
+ {
9
+ default: { height: 800, width: 480 }
10
+ }
11
+ end
13
12
 
14
- def call(&block)
15
- conversion.call(&block)
16
- end
13
+ private
17
14
 
18
- private
15
+ def extension
16
+ 'mp4'
17
+ end
19
18
 
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
19
+ def conversion(input, output)
20
+ Media.convert do |c|
21
+ c.options y: true
22
+
23
+ c.input input
24
+
25
+ c.output output do |o|
26
+ o.options(
27
+ acodec: 'aac',
28
+ strict: 'experimental',
29
+ ab: '96k',
30
+ s: Media.size(width: preset.width, height: preset.height),
31
+ vcodec: 'libx264',
32
+ preset: 'slow',
33
+ f: 'mp4',
34
+ crf: 22
35
+ )
38
36
  end
39
37
  end
40
38
  end
@@ -1,45 +1,36 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module Playstation
4
- extend self
5
+ class Playstation < Base
5
6
 
6
- def presets
7
+ def self.presets
7
8
  {
8
9
  psp: {height: 240, width: 320}
9
10
  }
10
11
  end
11
12
 
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
13
+ private
24
14
 
25
- private
15
+ def extension
16
+ 'mp4'
17
+ end
26
18
 
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
19
+ def conversion(input, output)
20
+ Media.convert do |c|
21
+ c.options y: true
22
+
23
+ c.input input
24
+
25
+ c.output output do |o|
26
+ o.options(
27
+ s: Media.size(width: preset.width, height: preset.height),
28
+ b: 512000,
29
+ ar: 24000,
30
+ ab: 64000,
31
+ f: 'psp',
32
+ r: 29.97
33
+ )
43
34
  end
44
35
  end
45
36
  end
@@ -1,47 +1,36 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module ProRes
4
- extend self
5
-
6
- def presets
5
+ class ProRes < Base
6
+
7
+ def self.presets
7
8
  {
8
9
  normal_1080p: {height: 1080, width: 1920, profile: 2},
9
10
  normal_720p: {height: 720, width: 1280, profile: 2}
10
11
  }
11
12
  end
12
13
 
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
14
+ private
27
15
 
28
- private
16
+ def extension
17
+ 'mov'
18
+ end
29
19
 
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
20
+ def conversion(input, output)
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
+ s: Media.size(width: preset.width, height: preset.height),
29
+ vcodec: 'prores',
30
+ profile: preset.profile,
31
+ acodec: 'pcm_s16be',
32
+ ar: 48000
33
+ )
45
34
  end
46
35
  end
47
36
  end
@@ -1,35 +1,33 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module Theora
5
+ class Theora < Base
4
6
 
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
7
+ def self.presets
8
+ {
9
+ default: {}
10
+ }
11
+ end
13
12
 
14
- def call(&block)
15
- conversion.call(&block)
16
- end
13
+ private
17
14
 
18
- private
15
+ def extension
16
+ '.ogv'
17
+ end
19
18
 
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
19
+ def conversion(input, output)
20
+ Media.convert do |c|
21
+ c.options y: true
22
+
23
+ c.input input
24
+
25
+ c.output output do |o|
26
+ o.options(
27
+ f: 'ogg',
28
+ acodec: 'libvorbis',
29
+ aq: 60
30
+ )
33
31
  end
34
32
  end
35
33
  end
@@ -1,5 +1,5 @@
1
1
  module Media
2
2
  module Preset
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
@@ -1,33 +1,34 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module Vorbis
5
+ class Vorbis < Base
4
6
 
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
7
+ def self.presets
8
+ {
9
+ default: {}
10
+ }
11
+ end
14
12
 
15
- private
13
+ private
16
14
 
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
15
+ def extension
16
+ '.oga'
17
+ end
18
+
19
+ def conversion(input, output)
20
+ Media.convert do |c|
21
+ c.options y: true
22
+
23
+ c.input input
24
+
25
+ c.output output do |o|
26
+ o.options(
27
+ f: 'ogg',
28
+ vn: true,
29
+ acodec: 'libvorbis',
30
+ aq: 60
31
+ )
31
32
  end
32
33
  end
33
34
  end
@@ -1,60 +1,46 @@
1
+ require_relative 'base'
2
+
1
3
  module Media
2
4
  module Preset
3
- module WebM
4
- extend self
5
+ class WebM < Base
5
6
 
6
- def presets
7
+ def self.presets
7
8
  {
8
9
  hd: {height: 720, width: 1280, qmax: 51, qmin: 11, slices: 4, video_bitrate: '2M'},
9
10
  sd: {height: 480, width: 640, qmax: 63, qmin: 0, slices: 1, video_bitrate: '768K'}
10
11
  }
11
12
  end
12
13
 
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
14
+ private
30
15
 
31
- private
16
+ def extension
17
+ 'webm'
18
+ end
32
19
 
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
20
+ def conversion(input, output)
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
+ s: Media.size(width: preset.width, height: preset.height),
29
+ vcodec: 'libvpx',
30
+ g: 120,
31
+ 'lag-in-frames' => 16,
32
+ deadline: 'good',
33
+ 'cpu-used' => 0,
34
+ vprofile: 0,
35
+ qmax: preset.qmax,
36
+ qmin: preset.qmin,
37
+ slices: preset.slices,
38
+ 'b:v' => preset.video_bitrate,
39
+ acodec: 'libvorbis',
40
+ ab: '112k',
41
+ ar: 44100,
42
+ f: 'webm'
43
+ )
58
44
  end
59
45
  end
60
46
  end
metadata CHANGED
@@ -2,16 +2,22 @@
2
2
  name: media-preset
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jamie Hodge
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-21 00:00:00.000000000 Z
12
+ date: 2013-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.4
20
+ none: false
15
21
  prerelease: false
16
22
  type: :runtime
17
23
  name: media
@@ -21,13 +27,13 @@ dependencies:
21
27
  - !ruby/object:Gem::Version
22
28
  version: 0.0.4
23
29
  none: false
30
+ - !ruby/object:Gem::Dependency
24
31
  version_requirements: !ruby/object:Gem::Requirement
25
32
  requirements:
26
- - - ~>
33
+ - - ! '>='
27
34
  - !ruby/object:Gem::Version
28
- version: 0.0.4
35
+ version: '0'
29
36
  none: false
30
- - !ruby/object:Gem::Dependency
31
37
  prerelease: false
32
38
  type: :development
33
39
  name: rake
@@ -37,13 +43,13 @@ dependencies:
37
43
  - !ruby/object:Gem::Version
38
44
  version: '0'
39
45
  none: false
46
+ - !ruby/object:Gem::Dependency
40
47
  version_requirements: !ruby/object:Gem::Requirement
41
48
  requirements:
42
49
  - - ! '>='
43
50
  - !ruby/object:Gem::Version
44
51
  version: '0'
45
52
  none: false
46
- - !ruby/object:Gem::Dependency
47
53
  prerelease: false
48
54
  type: :development
49
55
  name: minitest
@@ -53,12 +59,6 @@ dependencies:
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0'
55
61
  none: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ! '>='
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- none: false
62
62
  description: Media presets
63
63
  email:
64
64
  - jamiehodge@me.com
@@ -80,6 +80,8 @@ files:
80
80
  bGliL21lZGlhL3ByZXNldC9hbmRyb2lkLnJi
81
81
  - !binary |-
82
82
  bGliL21lZGlhL3ByZXNldC9hcHBsZS5yYg==
83
+ - !binary |-
84
+ bGliL21lZGlhL3ByZXNldC9iYXNlLnJi
83
85
  - !binary |-
84
86
  bGliL21lZGlhL3ByZXNldC9oMjY0LnJi
85
87
  - !binary |-