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.
14 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 |
# File 'lib/video_converter/output.rb', line 14 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.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def chunks_dir @chunks_dir end |
#crop ⇒ Object
Returns the value of attribute crop.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def crop @crop end |
#drm ⇒ Object
Returns the value of attribute drm.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def drm @drm end |
#encryption_key ⇒ Object
Returns the value of attribute encryption_key.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def encryption_key @encryption_key end |
#encryption_key_url ⇒ Object
Returns the value of attribute encryption_key_url.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def encryption_key_url @encryption_key_url end |
#faststart ⇒ Object
Returns the value of attribute faststart.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def faststart @faststart end |
#ffmpeg_output ⇒ Object
Returns the value of attribute ffmpeg_output.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def ffmpeg_output @ffmpeg_output end |
#filename ⇒ Object
Returns the value of attribute filename.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def filename @filename end |
#group ⇒ Object
Returns the value of attribute group.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def group @group end |
#height ⇒ Object
Returns the value of attribute height.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def height @height end |
#log ⇒ Object
Returns the value of attribute log.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def log @log end |
#mkdir_mode ⇒ Object
Returns the value of attribute mkdir_mode.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def mkdir_mode @mkdir_mode end |
#no_fragments ⇒ Object
Returns the value of attribute no_fragments.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def no_fragments @no_fragments end |
#one_pass ⇒ Object
Returns the value of attribute one_pass.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def one_pass @one_pass end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def @options end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def path @path end |
#rotate ⇒ Object
Returns the value of attribute rotate.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def rotate @rotate end |
#streams ⇒ Object
Returns the value of attribute streams.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def streams @streams end |
#thumbnails ⇒ Object
Returns the value of attribute thumbnails.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def thumbnails @thumbnails end |
#type ⇒ Object
Returns the value of attribute type.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def type @type end |
#uid ⇒ Object
Returns the value of attribute uid.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def uid @uid end |
#volume ⇒ Object
Returns the value of attribute volume.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def volume @volume end |
#watermarks ⇒ Object
Returns the value of attribute watermarks.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def watermarks @watermarks end |
#width ⇒ Object
Returns the value of attribute width.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def width @width end |
#work_dir ⇒ Object
Returns the value of attribute work_dir.
12 13 14 |
# File 'lib/video_converter/output.rb', line 12 def work_dir @work_dir end |
Instance Method Details
#output_group(outputs) ⇒ Object
45 46 47 48 |
# File 'lib/video_converter/output.rb', line 45 def output_group(outputs) paths = streams.map { |stream| stream[:path] } outputs.select { |output| paths.include?(output.filename) }.unshift(self) end |