Class: Falcon::Profile
- Inherits:
-
Object
- Object
- Falcon::Profile
- Defined in:
- lib/falcon/profile.rb
Constant Summary collapse
- DEFAULTS =
{ :player => 'flash', :container => "mp4", :extname => 'mp4', :width => 480, :height => 320, :fps => 29.97, :video_codec => "libx264", :video_bitrate => 500, :command => nil, :audio_codec => "libfaac", :audio_bitrate => 128, :audio_sample_rate => 48000 }
- @@all =
[]
Instance Attribute Summary collapse
-
#audio_bitrate ⇒ Object
Returns the value of attribute audio_bitrate.
-
#audio_codec ⇒ Object
Returns the value of attribute audio_codec.
-
#audio_sample_rate ⇒ Object
Returns the value of attribute audio_sample_rate.
-
#command ⇒ Object
Returns the value of attribute command.
-
#container ⇒ Object
Returns the value of attribute container.
-
#extname ⇒ Object
Returns the value of attribute extname.
-
#fps ⇒ Object
Returns the value of attribute fps.
-
#height ⇒ Object
Returns the value of attribute height.
-
#name ⇒ Object
Returns the value of attribute name.
-
#player ⇒ Object
Returns the value of attribute player.
-
#video_bitrate ⇒ Object
Returns the value of attribute video_bitrate.
-
#video_codec ⇒ Object
Returns the value of attribute video_codec.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #audio_bitrate_in_bits ⇒ Object
- #encode_options ⇒ Object
-
#initialize(name, options = {}) ⇒ Profile
constructor
A new instance of Profile.
- #path(source, prefix = nil) ⇒ Object
- #update(options) ⇒ Object
- #video_bitrate_in_bits ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Profile
Returns a new instance of Profile.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/falcon/profile.rb', line 25 def initialize(name, = {}) .assert_valid_keys(DEFAULTS.keys) = DEFAULTS.merge() @name = name.to_s if self.class.exists?(@name) raise "Profile name: #{@name} already registered." end .each do |key, value| send("#{key}=", value) end @@all << self end |
Instance Attribute Details
#audio_bitrate ⇒ Object
Returns the value of attribute audio_bitrate.
8 9 10 |
# File 'lib/falcon/profile.rb', line 8 def audio_bitrate @audio_bitrate end |
#audio_codec ⇒ Object
Returns the value of attribute audio_codec.
8 9 10 |
# File 'lib/falcon/profile.rb', line 8 def audio_codec @audio_codec end |
#audio_sample_rate ⇒ Object
Returns the value of attribute audio_sample_rate.
8 9 10 |
# File 'lib/falcon/profile.rb', line 8 def audio_sample_rate @audio_sample_rate end |
#command ⇒ Object
Returns the value of attribute command.
6 7 8 |
# File 'lib/falcon/profile.rb', line 6 def command @command end |
#container ⇒ Object
Returns the value of attribute container.
6 7 8 |
# File 'lib/falcon/profile.rb', line 6 def container @container end |
#extname ⇒ Object
Returns the value of attribute extname.
6 7 8 |
# File 'lib/falcon/profile.rb', line 6 def extname @extname end |
#fps ⇒ Object
Returns the value of attribute fps.
6 7 8 |
# File 'lib/falcon/profile.rb', line 6 def fps @fps end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/falcon/profile.rb', line 6 def height @height end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/falcon/profile.rb', line 6 def name @name end |
#player ⇒ Object
Returns the value of attribute player.
6 7 8 |
# File 'lib/falcon/profile.rb', line 6 def player @player end |
#video_bitrate ⇒ Object
Returns the value of attribute video_bitrate.
7 8 9 |
# File 'lib/falcon/profile.rb', line 7 def video_bitrate @video_bitrate end |
#video_codec ⇒ Object
Returns the value of attribute video_codec.
7 8 9 |
# File 'lib/falcon/profile.rb', line 7 def video_codec @video_codec end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/falcon/profile.rb', line 6 def width @width end |
Class Method Details
.[](name) ⇒ Object
83 84 85 |
# File 'lib/falcon/profile.rb', line 83 def [](name) find(name) end |
.detect(name) ⇒ Object
91 92 93 |
# File 'lib/falcon/profile.rb', line 91 def detect(name) name.is_a?(Falcon::Profile) ? name : find(name.to_s) end |
.exists?(name) ⇒ Boolean
87 88 89 |
# File 'lib/falcon/profile.rb', line 87 def exists?(name) !find(name).nil? end |
.find(name) ⇒ Object Also known as: get
78 79 80 |
# File 'lib/falcon/profile.rb', line 78 def find(name) @@all.detect { |p| p.name == name.to_s } end |
Instance Method Details
#audio_bitrate_in_bits ⇒ Object
42 43 44 |
# File 'lib/falcon/profile.rb', line 42 def audio_bitrate_in_bits self.audio_bitrate.to_i * 1024 end |
#encode_options ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/falcon/profile.rb', line 58 def { :container => self.container, :video_codec => self.video_codec, :video_bitrate_in_bits => self.video_bitrate_in_bits.to_s, :fps => self.fps, :audio_codec => self.audio_codec.to_s, :audio_bitrate => self.audio_bitrate.to_s, :audio_bitrate_in_bits => self.audio_bitrate_in_bits.to_s, :audio_sample_rate => self.audio_sample_rate.to_s } end |
#path(source, prefix = nil) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/falcon/profile.rb', line 50 def path(source, prefix = nil) dirname = File.dirname(source) filename = File.basename(source, File.extname(source)) filename = [prefix, filename].compact.join('_') + '.' + extname Pathname.new(File.join(dirname, filename)) end |
#update(options) ⇒ Object
71 72 73 74 75 |
# File 'lib/falcon/profile.rb', line 71 def update() .each do |key, value| send("#{key}=", value) end end |
#video_bitrate_in_bits ⇒ Object
46 47 48 |
# File 'lib/falcon/profile.rb', line 46 def video_bitrate_in_bits self.video_bitrate.to_i * 1024 end |