<commit_before>module CarrierWave
  module Video
    class FfmpegOptions
      attr_reader :format, :resolution, :custom, :callbacks

      def initialize(format, options)
        @format = format.to_s
        @resolution = options[:resolution] || "640x360"
        @custom = options[:custom]
        @callbacks = options[:callbacks] || {}
        @logger = options[:logger]
        @unparsed = options
        @progress = options[:progress]

        @format_options = defaults.merge(options)
      end

      def raw
        @unparsed
      end

      def logger(model)
        model.send(@logger) if @logger.present?
      end

      def progress(model)
        lambda {|val| model.send(@progress, val)}
      end

      def encoder_options
        { preserve_aspect_ratio: :width }
      end

      # input
      def format_options
        @format_options
      end

      # output
      def format_params
        params = @format_options.dup
        params[:custom] = [params[:custom], watermark_params].compact.join(' ')
        params
      end

      def watermark?
        @format_options[:watermark].present?
      end

      def watermark_params
        return nil unless watermark?

        @watermark_params ||= begin
          path = @format_options[:watermark][:path]
          position = @format_options[:watermark][:position].to_s || :bottom_right<commit_msg>model.send(@progress, val) error if @progress is not specified<commit_after>module CarrierWave
  module Video
    class FfmpegOptions
      attr_reader :format, :resolution, :custom, :callbacks

      def initialize(format, options)
        @format = format.to_s
        @resolution = options[:resolution] || "640x360"
        @custom = options[:custom]
        @callbacks = options[:callbacks] || {}
        @logger = options[:logger]
        @unparsed = options
        @progress = options[:progress]

        @format_options = defaults.merge(options)
      end

      def raw
        @unparsed
      end

      def logger(model)
        model.send(@logger) if @logger.present?
      end

      def progress(model)
        lambda {|val| model.send(@progress, val)} if @progress
      end

      def encoder_options
        { preserve_aspect_ratio: :width }
      end

      # input
      def format_options
        @format_options
      end

      # output
      def format_params
        params = @format_options.dup
        params[:custom] = [params[:custom], watermark_params].compact.join(' ')
        params
      end

      def watermark?
        @format_options[:watermark].present?
      end

      def watermark_params
        return nil unless watermark?

        @watermark_params ||= begin
          path = @format_options[:watermark][:path]
          position = @format_options[:watermark][:position].to_s || :bottom_right
{'fraction_non_alphanumeric': 0.09850640113798008, 'fraction_numerical': 0.004267425320056899, 'mean_word_length': 2.2595596755504057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7136054', 'n_tokens_mistral': 802, 'n_tokens_neox': 771, 'n_words': 180}