lib/viddl/video/clip.rb
def command_line(options = {})
        if options.empty? || options.keys == [:output_path]
          # when there are no clip options, the source file can just be copied
          # over to the output file path without using ffmpeg
          populate_output_path(options)
          "cp #{@source_path} #{@path.to_s}"
        else
          formatted_opts = options_formatted(options)

          modules_with_args = MODULES.select { |mod| mod.respond_to?(:args) }
          modules_with_filters = MODULES.select { |mod| mod.respond_to?(:filter_args) }

          module_args = modules_with_args.map { |mod| mod.args(formatted_opts) }.compact
          module_filters = modules_with_filters.map { |mod| mod.filter_args(formatted_opts) }.compact

          module_arg_string = module_args.join(" ")
          unless module_filters.empty?
            module_arg_string += " -vf '#{module_filters.join(",")}'"
          end

          populate_output_path(formatted_opts)
          "ffmpeg -i #{@source_path} #{options[:flags]} #{module_arg_string} #{@path.to_s}"
        end
      end
# Command line to create a clip from the source file and given options
# @param [Hash] options
# @option options [Boolean] :audio Whether to include audio
# @option options [String] :flags Flags to pass to ffmpeg
# @option options [Numeric] :start Time in the source file where the clip starts
# @option options [Numeric] :duration Duration of the clip
# @option options [Numeric] :end Time in the source file where the clip ends
# @option options [Integer, String] :width The desired width to resize to
# @option options [Integer, String] :height The desired height to resize to
# @option options [Hash] :crop The desired crop parameters (:x, :y, :width, :height)
# @option options [Pathname, String] :output_path Path where clip will be written
# @return [String]
Command line to create a clip from the source file and given options
Command line to create a clip from the source file and given options
def command_line(options = {})
        if options.empty? || options.keys == [:output_path]
          populate_output_path(options)
          "cp #{@source_path} #{@path.to_s}"
        else
          formatted_opts = options_formatted(options)
          modules_with_args = MODULES.select { |mod| mod.respond_to?(:args) }
          modules_with_filters = MODULES.select { |mod| mod.respond_to?(:filter_args) }
          module_args = modules_with_args.map { |mod| mod.args(formatted_opts) }.compact
          module_filters = modules_with_filters.map { |mod| mod.filter_args(formatted_opts) }.compact
          module_arg_string = module_args.join(" ")
          unless module_filters.empty?
            module_arg_string += " -vf '#{module_filters.join(",")}'"
          end
          populate_output_path(formatted_opts)
          "ffmpeg -i #{@source_path} #{options[:flags]} #{module_arg_string} #{@path.to_s}"
        end
      end
def command_line ( options = { } ) if options . empty? || options . keys == [ :output_path ] populate_output_path ( options ) "cp #{@source_path} #{@path.to_s}" else formatted_opts = options_formatted ( options ) modules_with_args = MODULES . select { | mod | mod . respond_to? ( :args ) } modules_with_filters = MODULES . select { | mod | mod . respond_to? ( :filter_args ) } module_args = modules_with_args . map { | mod | mod . args ( formatted_opts ) } . compact module_filters = modules_with_filters . map { | mod | mod . filter_args ( formatted_opts ) } . compact module_arg_string = module_args . join ( " " ) unless module_filters . empty? module_arg_string += " -vf '#{module_filters.join(",")}'" end populate_output_path ( formatted_opts ) "ffmpeg -i #{@source_path} #{options[:flags]} #{module_arg_string} #{@path.to_s}" end end
Command line to create a clip from the source file and given options
Command line to create a clip from the source file and given options
# when there are no clip options, the source file can just be copied # over to the output file path without using ffmpeg
None
String
options
:output_path Path where clip will be written
: output_path Path where clip will be written
None