Class: EncodingDotCom::Format
- Inherits:
-
Object
- Object
- EncodingDotCom::Format
- Defined in:
- lib/encoding_dot_com/format.rb
Constant Summary collapse
- OUTPUTS =
[:"3gp", :appletv, :fl9, :flv, :iphone, :ipod, :m4v, :mp3, :mp4, :psp, :wma, :wmv, :zune]
- VIDEO_CODECS =
[:flv, :libx264, :mpeg4, :msmpeg4, :h263, :vp6, :wmv2]
- AUDIO_CODECS =
[:libmp3lame, :libfaac, :wmav2, :libamr_nb]
- BOOLEAN_FIELDS =
[:stereo, :two_pass, :constant_bitrate, :deinterlace, :turbo]
- INTEGER_FIELDS =
[:video_bitrate, :framerate, :audio_bitrate, :audio_sample_rate, :max_bitrate, :min_bitrate, :key_frame_interval ]
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.
-
#constant_bitrate ⇒ Object
Returns the value of attribute constant_bitrate.
-
#deinterlace ⇒ Object
Returns the value of attribute deinterlace.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#dimensions ⇒ Object
Returns the value of attribute dimensions.
-
#framerate ⇒ Object
Returns the value of attribute framerate.
-
#key_frame_interval ⇒ Object
Returns the value of attribute key_frame_interval.
-
#max_bitrate ⇒ Object
Returns the value of attribute max_bitrate.
-
#min_bitrate ⇒ Object
Returns the value of attribute min_bitrate.
-
#output ⇒ Object
Returns the value of attribute output.
-
#stereo ⇒ Object
Returns the value of attribute stereo.
-
#turbo ⇒ Object
Returns the value of attribute turbo.
-
#two_pass ⇒ Object
Returns the value of attribute two_pass.
-
#video_bitrate ⇒ Object
Returns the value of attribute video_bitrate.
-
#video_codec ⇒ Object
Returns the value of attribute video_codec.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Format
constructor
A new instance of Format.
- #to_hash ⇒ Object
- #to_xml(options = {}) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Format
28 29 30 31 32 33 |
# File 'lib/encoding_dot_com/format.rb', line 28 def initialize(attributes = {}) self.output = attributes.delete(:output) attributes.each do |key, value| send("#{key}=", value) end end |
Instance Attribute Details
#audio_bitrate ⇒ Object
Returns the value of attribute audio_bitrate.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def audio_bitrate @audio_bitrate end |
#audio_codec ⇒ Object
Returns the value of attribute audio_codec.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def audio_codec @audio_codec end |
#audio_sample_rate ⇒ Object
Returns the value of attribute audio_sample_rate.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def audio_sample_rate @audio_sample_rate end |
#constant_bitrate ⇒ Object
Returns the value of attribute constant_bitrate.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def constant_bitrate @constant_bitrate end |
#deinterlace ⇒ Object
Returns the value of attribute deinterlace.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def deinterlace @deinterlace end |
#destination ⇒ Object
Returns the value of attribute destination.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def destination @destination end |
#dimensions ⇒ Object
Returns the value of attribute dimensions.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def dimensions @dimensions end |
#framerate ⇒ Object
Returns the value of attribute framerate.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def framerate @framerate end |
#key_frame_interval ⇒ Object
Returns the value of attribute key_frame_interval.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def key_frame_interval @key_frame_interval end |
#max_bitrate ⇒ Object
Returns the value of attribute max_bitrate.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def max_bitrate @max_bitrate end |
#min_bitrate ⇒ Object
Returns the value of attribute min_bitrate.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def min_bitrate @min_bitrate end |
#output ⇒ Object
Returns the value of attribute output.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def output @output end |
#stereo ⇒ Object
Returns the value of attribute stereo.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def stereo @stereo end |
#turbo ⇒ Object
Returns the value of attribute turbo.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def turbo @turbo end |
#two_pass ⇒ Object
Returns the value of attribute two_pass.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def two_pass @two_pass end |
#video_bitrate ⇒ Object
Returns the value of attribute video_bitrate.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def video_bitrate @video_bitrate end |
#video_codec ⇒ Object
Returns the value of attribute video_codec.
10 11 12 |
# File 'lib/encoding_dot_com/format.rb', line 10 def video_codec @video_codec end |
Instance Method Details
#to_hash ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/encoding_dot_com/format.rb', line 168 def to_hash hash = { :output => output, :stereo => stereo, :turbo => turbo } hash[:dimensions] = dimensions unless dimensions.nil? hash[:video_bitrate] = video_bitrate unless video_bitrate.nil? hash[:framerate] = framerate unless framerate.nil? hash[:video_codec] = video_codec unless video_codec.nil? hash[:audio_bitrate] = audio_bitrate unless audio_bitrate.nil? hash[:audio_sample_rate] = audio_sample_rate unless audio_sample_rate.nil? hash[:audio_codec] = audio_codec unless audio_codec.nil? hash[:two_pass] = two_pass unless two_pass.nil? hash[:constant_bitrate] = constant_bitrate unless constant_bitrate.nil? hash[:max_bitrate] = max_bitrate unless max_bitrate.nil? hash[:min_bitrate] = min_bitrate unless min_bitrate.nil? hash[:key_frame_interval] = key_frame_interval unless key_frame_interval.nil? hash[:deinterlace] = deinterlace unless deinterlace.nil? hash end |
#to_xml(options = {}) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/encoding_dot_com/format.rb', line 144 def to_xml( = {}) xml = [:builder] ||= ::Builder::XmlMarkup.new(:indent => [:indent] ||= 2) xml.format do xml.output(output.to_s) xml.video_codec(video_codec.to_s) if video_codec xml.audio_codec(audio_codec.to_s) if audio_codec xml.bitrate("#{video_bitrate}k") if video_bitrate xml.audio_bitrate("#{audio_bitrate}k") if audio_bitrate xml.audio_sample_rate(audio_sample_rate.to_s) if audio_sample_rate xml.size("#{dimensions[0]}x#{dimensions[1]}") if dimensions xml.minrate("#{min_bitrate}k") if min_bitrate xml.maxrate("#{max_bitrate}k") if max_bitrate xml.keyframe(key_frame_interval) if key_frame_interval xml.framerate(framerate.is_a?(Array) ? "#{framerate[0]}/#{framerate[1]}" : framerate.to_s) if framerate xml.audio_channels_number(stereo ? '2' : '1') unless stereo.nil? xml.two_pass(two_pass ? 'yes' : 'no') unless two_pass.nil? xml.cbr(constant_bitrate ? 'yes' : 'no') unless constant_bitrate.nil? xml.deinterlacing(deinterlace ? 'yes' : 'no') unless deinterlace.nil? xml.destination(destination) unless destination.nil? xml.turbo(turbo ? 'yes' : 'no') unless turbo.nil? end end |