Class: MultimediaParadise::Video::Resolution
- Inherits:
-
Base
- Object
- Base
- MultimediaParadise::Video::Resolution
show all
- Defined in:
- lib/multimedia_paradise/video/resolution.rb
Overview
Constant Summary
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
#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 = nil, run_already = true) ⇒ Resolution
25
26
27
28
29
30
31
32
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 25
def initialize(
i = nil,
run_already = true
)
reset
set_input(i)
run if run_already
end
|
Instance Method Details
#dataset? ⇒ Boolean
Also known as:
data?
75
76
77
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 75
def dataset?
@dataset
end
|
#filter_dataset ⇒ Object
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 82
def filter_dataset
begin
@dataset = @dataset.split(N)
@dataset.select! {|entry| entry.include? 'Stream ' } @dataset.select! {|entry| entry.include?('x') and entry.include?('Video:') }
rescue ArgumentError => error
e 'Error for this file: '+this_file?
pp error
end
end
|
#grab_resolution_from_the_dataset ⇒ Object
#
grab_resolution_from_the_dataset
#
96
97
98
99
100
101
102
103
104
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 96
def grab_resolution_from_the_dataset
_ = dataset?
if _ and _.respond_to?(:first) and !_.first.nil?
_ = _.first.strip
use_this_regex = / (\d{1,4}x\d{1,4}),? / _ =~ use_this_regex
set_resolution $1.to_s.dup
end
end
|
#guess_width_and_height(i = @resolution) ⇒ Object
#
guess_width_and_height
#
117
118
119
120
121
122
123
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 117
def guess_width_and_height(i = @resolution)
if i.include? 'x'
splitted = i.split('x')
@width = splitted.first
@height = splitted.last
end
end
|
#height? ⇒ Boolean
135
136
137
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 135
def height?
@height
end
|
54
55
56
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 54
def input?
@input
end
|
#obtain_dataset_via_ffmpeg(input = input?
) ⇒ Object
#
obtain_dataset_via_ffmpeg
#
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 61
def obtain_dataset_via_ffmpeg(
input = input?
)
if input.nil?
e 'Please supply a valid argument, a video or audio file.'
else
_ = 'ffmpeg -i '+input+' 2>&1'
@dataset = `#{_}`
end
end
|
#report_resolution(i = input?
) ⇒ Object
Also known as:
report
#
report_resolution
This method has to be called externally, as this class will not automatically invoke it.
#
145
146
147
148
149
150
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 145
def report_resolution(
i = input?
)
e "#{rev}The resolution of #{sfile(i)} is:"
e " #{simp(res?)}"
end
|
#reset ⇒ Object
37
38
39
40
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 37
def reset
super()
@dataset = nil
end
|
#resolution? ⇒ Boolean
Also known as:
res?, the_resolution_is?
156
157
158
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 156
def resolution?
@resolution
end
|
#run ⇒ Object
164
165
166
167
168
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 164
def run
obtain_dataset_via_ffmpeg
filter_dataset
grab_resolution_from_the_dataset
end
|
45
46
47
48
49
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 45
def set_input(i = '')
i = i.first if i.is_a? Array
i = i.to_s.dup if i
@input = i
end
|
#set_resolution(i = nil) ⇒ Object
109
110
111
112
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 109
def set_resolution(i = nil)
@resolution = i
guess_width_and_height if @resolution
end
|
#width? ⇒ Boolean
128
129
130
|
# File 'lib/multimedia_paradise/video/resolution.rb', line 128
def width?
@width
end
|