Class: VideoConverter::Output
Class Attribute Summary collapse
-
.keyframe_interval_in_seconds ⇒ Object
Returns the value of attribute keyframe_interval_in_seconds.
-
.log ⇒ Object
Returns the value of attribute log.
-
.work_dir ⇒ Object
Returns the value of attribute work_dir.
Instance Attribute Summary collapse
-
#chunks_dir ⇒ Object
Returns the value of attribute chunks_dir.
-
#crop ⇒ Object
Returns the value of attribute crop.
-
#drm ⇒ Object
Returns the value of attribute drm.
-
#encryption_key ⇒ Object
Returns the value of attribute encryption_key.
-
#encryption_key_url ⇒ Object
Returns the value of attribute encryption_key_url.
-
#faststart ⇒ Object
Returns the value of attribute faststart.
-
#ffmpeg_output ⇒ Object
Returns the value of attribute ffmpeg_output.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#group ⇒ Object
Returns the value of attribute group.
-
#height ⇒ Object
Returns the value of attribute height.
-
#log ⇒ Object
Returns the value of attribute log.
-
#mkdir_mode ⇒ Object
Returns the value of attribute mkdir_mode.
-
#no_fragments ⇒ Object
Returns the value of attribute no_fragments.
-
#one_pass ⇒ Object
Returns the value of attribute one_pass.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
-
#rotate ⇒ Object
Returns the value of attribute rotate.
-
#streams ⇒ Object
Returns the value of attribute streams.
-
#thumbnails ⇒ Object
Returns the value of attribute thumbnails.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#volume ⇒ Object
Returns the value of attribute volume.
-
#watermarks ⇒ Object
Returns the value of attribute watermarks.
-
#width ⇒ Object
Returns the value of attribute width.
-
#work_dir ⇒ Object
Returns the value of attribute work_dir.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Output
constructor
A new instance of Output.
- #output_group(outputs) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Output
Returns a new instance of Output.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/video_converter/output.rb', line 15 def initialize params = {} self.work_dir = File.join(self.class.work_dir, params[:uid]) self.mkdir_mode = params[:mkdir_mode] self.mkdir_mode = mkdir_mode.to_i(8) if mkdir_mode.is_a?(String) FileUtils.mkdir_p(work_dir, :mode => mkdir_mode) self.filename = params[:filename] or raise ArgumentError.new('Filename required') self.log = File.join(work_dir, self.class.log) self.type = params[:type] || 'default' if type == 'segmented' self.chunks_dir = File.join(work_dir, File.basename(filename, '.*')) FileUtils.mkdir_p(chunks_dir, :mode => mkdir_mode) if File.extname(filename) == '.m3u8' self.ffmpeg_output = chunks_dir + '.ts' params[:format] = 'mpegts' elsif File.extname(filename) == '.f4m' self.ffmpeg_output = chunks_dir = '.mp4' params[:format] = 'mp4' else raise "Invalid filename for type segmented" end else self.ffmpeg_output = File.join(work_dir, filename) end raise ArgumentError.new('Invalid type') unless %w(default segmented playlist).include?(type) [:path, :streams, :width, :height, :one_pass, :rotate, :faststart, :thumbnails, :group, :drm, :no_fragments, :crop, :watermarks, :volume, :encryption_key, :encryption_key_url].each { |attr| self.send("#{attr}=", params[attr]) } [:video_bitrate, :audio_bitrate].each { |bitrate| params[bitrate] = "#{params[bitrate]}k" if params[bitrate].is_a?(Numeric) } # options will be substituted to convertation commands self. = params end |
Class Attribute Details
.keyframe_interval_in_seconds ⇒ Object
Returns the value of attribute keyframe_interval_in_seconds.
6 7 8 |
# File 'lib/video_converter/output.rb', line 6 def keyframe_interval_in_seconds @keyframe_interval_in_seconds end |
.log ⇒ Object
Returns the value of attribute log.
6 7 8 |
# File 'lib/video_converter/output.rb', line 6 def log @log end |
.work_dir ⇒ Object
Returns the value of attribute work_dir.
6 7 8 |
# File 'lib/video_converter/output.rb', line 6 def work_dir @work_dir end |
Instance Attribute Details
#chunks_dir ⇒ Object
Returns the value of attribute chunks_dir.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def chunks_dir @chunks_dir end |
#crop ⇒ Object
Returns the value of attribute crop.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def crop @crop end |
#drm ⇒ Object
Returns the value of attribute drm.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def drm @drm end |
#encryption_key ⇒ Object
Returns the value of attribute encryption_key.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def encryption_key @encryption_key end |
#encryption_key_url ⇒ Object
Returns the value of attribute encryption_key_url.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def encryption_key_url @encryption_key_url end |
#faststart ⇒ Object
Returns the value of attribute faststart.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def faststart @faststart end |
#ffmpeg_output ⇒ Object
Returns the value of attribute ffmpeg_output.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def ffmpeg_output @ffmpeg_output end |
#filename ⇒ Object
Returns the value of attribute filename.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def filename @filename end |
#group ⇒ Object
Returns the value of attribute group.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def group @group end |
#height ⇒ Object
Returns the value of attribute height.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def height @height end |
#log ⇒ Object
Returns the value of attribute log.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def log @log end |
#mkdir_mode ⇒ Object
Returns the value of attribute mkdir_mode.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def mkdir_mode @mkdir_mode end |
#no_fragments ⇒ Object
Returns the value of attribute no_fragments.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def no_fragments @no_fragments end |
#one_pass ⇒ Object
Returns the value of attribute one_pass.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def one_pass @one_pass end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def @options end |
#path ⇒ Object
Returns the value of attribute path.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def path @path end |
#rotate ⇒ Object
Returns the value of attribute rotate.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def rotate @rotate end |
#streams ⇒ Object
Returns the value of attribute streams.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def streams @streams end |
#thumbnails ⇒ Object
Returns the value of attribute thumbnails.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def thumbnails @thumbnails end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def type @type end |
#uid ⇒ Object
Returns the value of attribute uid.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def uid @uid end |
#volume ⇒ Object
Returns the value of attribute volume.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def volume @volume end |
#watermarks ⇒ Object
Returns the value of attribute watermarks.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def watermarks @watermarks end |
#width ⇒ Object
Returns the value of attribute width.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def width @width end |
#work_dir ⇒ Object
Returns the value of attribute work_dir.
13 14 15 |
# File 'lib/video_converter/output.rb', line 13 def work_dir @work_dir end |
Instance Method Details
#output_group(outputs) ⇒ Object
46 47 48 49 |
# File 'lib/video_converter/output.rb', line 46 def output_group(outputs) paths = streams.map { |stream| stream[:path] } outputs.select { |output| paths.include?(output.filename) }.unshift(self) end |