Class: MultimediaParadise::FfmpegOptions

Inherits:
Base
  • Object
show all
Defined in:
lib/multimedia_paradise/video/ffmpeg_options.rb

Constant Summary collapse

VIDEO_FILTER_ALIASES =
{}
REVERTED_VIDEO_FILTER_ALIASES =
#

REVERTED_VIDEO_FILTER_ALIASES

#
VIDEO_FILTER_ALIASES.invert
DEFAULT_STRING =
#

DEFAULT_STRING

#
'ffmpeg -i jokes.flv -ab 56 -ar 22050 -b 500 -s 320×240 jokes.mpg'
PADDING =
#

PADDING

#
'  '

Constants inherited from Base

Base::ERROR, Base::ERROR_LINE, Base::NAMESPACE, Base::USE_THIS_NAMESPACE_FOR_THE_COLOURS, Base::USE_THIS_NAMESPACE_FOR_THE_CORE_COLOURS

Instance Method Summary collapse

Methods inherited from Base

[], #actions, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #cartoons_directory?, #clear_the_internal_hash, #cliner, #cliner_with_time_stamp, #colourized_comment, #copy_file, #crimson, #dataset_from_file_video_collection, #dd_mm_yyyy, #debug?, #default_readlines, #directory_to_realvids?, #do_not_use_opn, #dodgerblue, #does_the_video_player_support_this_commandline?, #e, #ecomment, #ecrimson, #efancy, #enable_debug, #ensure_main_encoding, #ensure_that_the_output_directory_exists, #eparse, #erev, #esystem, #ewarn, #file_video_collection?, #filter_for_audio_files, #filter_for_video_files, #forestgreen, #gold, #grey, #hh_mm_ss, #home_x_video?, #indianred, #infer_the_namespace, #internal_hash?, #is_audio_file?, #is_mkv?, #is_mp3?, #is_mp4?, #is_multimedia_file?, #is_on_roebe?, #is_video_file?, #konsole_colour_peru, #lightblue, #lightgreen, #load_yaml, #local_audio_directory?, #log_dir?, #map_symbol_to_locally_existing_file, #mediumorchid, #mediumpurple, #mediumslateblue, #mkdir, #move_file, #namespace?, #no_file_exists, #no_file_exists_at, #olive, #olivedrab, #opne, #opnecomment, #opnn, #orange, #palegoldenrod, #palegreen, #powderblue, #project_base_directory?, #rds, #register_sigint, #remove_file, #report_pwd, #reset_the_internal_hash, #return_all_video_files, #return_pwd, #return_random_video, #rev, #royalblue, #save_what_into, #sdir, #seagreen, #seconds_to_time_format, #select_only_video_files_from, #set_be_verbose, #set_use_colours, #sfancy, #sfile, #simp, #skyblue, #slateblue, #springgreen, #steelblue, #swarn, #teal, #time_right_now, #to_hh_mm_ss, #tomato, #true_rev, #try_to_rename_kde_konsole_tab, #ucliner, #use_colours?, #use_opn?, #use_which_video_player?, #verbose_truth, #video_collection?, #violet, #yaml_directory?, #yel

Methods included from CommandlineArgumentsModule

#all_input_starts_with_a_number?, #commandline_arguments?, #commandline_arguments_as_a_string, #first_argument?, #first_non_hyphened_commandline_argument?, #set_commandline_arguments

Constructor Details

#initialize(i = DEFAULT_STRING, run_already = true) ⇒ FfmpegOptions

#

initialize

#


58
59
60
61
62
63
64
65
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 58

def initialize(
    i           = DEFAULT_STRING,
    run_already = true
  )
  reset
  set_string(i)
  run if run_already
end

Instance Method Details

#report_inputObject

#

report_input

#


124
125
126
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 124

def report_input
  e PADDING+@string
end

#report_resultObject

#

report_result

#


131
132
133
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 131

def report_result
  e PADDING+@result
end

#resetObject

#

reset

#


70
71
72
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 70

def reset
  super()
end

#runObject

#

run

#


148
149
150
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 148

def run
  run_everything
end

#run_everythingObject

#

run_everything

#


138
139
140
141
142
143
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 138

def run_everything
  set_keys
  sanitize_string
  report_input
  report_result
end

#sanitize_stringObject

#

sanitize_string

#


104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 104

def sanitize_string
  _ = ''.dup
  @string.split(' ').each { |x|
    if x.include? '-'
      if @keys.include? x[1..-1]
        _ << '-'+@keys[x[1..-1]]
      else
        _ << x
      end
    else
      _ << x
    end
    _ << ' '
  }
  @result = _
end

#set_keysObject

#

set_keys

#


77
78
79
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 77

def set_keys
  @keys = REVERTED_VIDEO_FILTER_ALIASES
end

#set_string(i) ⇒ Object

#

set_string

#


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/multimedia_paradise/video/ffmpeg_options.rb', line 84

def set_string(i)
  i = i.join(' ') if i.is_a? Array
  if i.empty?
    e 'Assigning default value to the string, as the passed string'+
      'is '+sfancy('empty')+'.'
    i = DEFAULT_STRING
  else
    case i
    when 'help' # Feedback help about codecs, then exit.
      system 'ffmpeg -codecs'
      exit
    end
  end
  i = i.strip
  @string = i
end