class Bagel::Video::FFMPEG::ConcatFile

Constants

FFMPEG_FILE_DIRECTIVE_PREFIX
MP4_PATTERN

Attributes

source[R]

Public Class Methods

create(source, &block) click to toggle source
# File lib/bagel/video/ffmpeg/concat_file.rb, line 8
def self.create(source, &block)
  new(source).create(&block)
end
new(source) click to toggle source
# File lib/bagel/video/ffmpeg/concat_file.rb, line 12
def initialize(source)
  @source = source
end

Public Instance Methods

create() { |path| ... } click to toggle source
# File lib/bagel/video/ffmpeg/concat_file.rb, line 16
def create
  Tempfile.create do |file|
    file.write(contents)
    file.flush
    yield(file.path)
  end
end

Private Instance Methods

absolute_path(path) click to toggle source
# File lib/bagel/video/ffmpeg/concat_file.rb, line 41
def absolute_path(path)
  File.expand_path(path)
end
contents() click to toggle source
# File lib/bagel/video/ffmpeg/concat_file.rb, line 26
def contents
  Dir.glob(MP4_PATTERN, base: source)
    .sort
    .map { |filename| ffmpeg_file_directive(filename) }
    .join("\n")
end
ffmpeg_file_directive(filename) click to toggle source
# File lib/bagel/video/ffmpeg/concat_file.rb, line 33
def ffmpeg_file_directive(filename)
  FFMPEG_FILE_DIRECTIVE_PREFIX + absolute_path(relative_path(filename))
end
relative_path(filename) click to toggle source
# File lib/bagel/video/ffmpeg/concat_file.rb, line 37
def relative_path(filename)
  File.join(source, filename)
end