Class: MultimediaParadise::CaptureScreen
- Inherits:
-
Base
- Object
- Base
- MultimediaParadise::CaptureScreen
show all
- Defined in:
- lib/multimedia_paradise/video/capture_screen.rb
Overview
Constant Summary
collapse
- DEFAULT_INPUT =
' -i :0.0'
- DEFAULT_STORE_IN_THIS_DIRECTORY =
#
DEFAULT_STORE_IN_THIS_DIRECTORY
This is currently hardcoded to the current working directory, but you could also use another target directory.
#
:pwd
- USE_THIS_SCREEN_RESOLUTION =
#
USE_THIS_SCREEN_RESOLUTION
#
'1920x1080'
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) ⇒ CaptureScreen
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 41
def initialize(
i = nil,
run_already = true
)
register_sigint
reset
case i
when :dont_run_yet
run_already = false
i = nil
end
run if run_already
end
|
Instance Method Details
#add(i) ⇒ Object
Also known as:
append
#
add (add tag)
This method will simply add to the main system command that will be run.
#
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 166
def add(i)
i = i.to_s unless i.is_a? String
i = i.dup if i.frozen?
i.strip!
i.prepend ' ' unless i.start_with? ' '
@run_this_command = @run_this_command.dup if @run_this_command.frozen?
@run_this_command << i
end
|
#add_audio_support ⇒ Object
#
add_audio_support
Use this method if you wish quick support for audio.
#
142
143
144
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 142
def add_audio_support
add ' -f alsa -ac 2 -i pulse'
end
|
#add_default_audio ⇒ Object
269
270
271
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 269
def add_default_audio
add ' -f alsa -ac 2 -i hw:0'
end
|
208
209
210
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 208
def add_default_format
add ' -f x11grab'
end
|
#add_default_framerate ⇒ Object
#
add_default_framerate
#
215
216
217
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 215
def add_default_framerate
add ' -framerate '+@framerate
end
|
201
202
203
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 201
def add_default_input
add DEFAULT_INPUT
end
|
#add_default_video_size ⇒ Object
#
add_default_video_size
#
222
223
224
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 222
def add_default_video_size
add ' -video_size '+resolution?
end
|
#build_up_main_string ⇒ Object
257
258
259
260
261
262
263
264
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 257
def build_up_main_string
add_default_video_size
add_default_framerate
add_default_format
overwrite_if_the_file_already_exists
add_default_input
add_default_audio
end
|
#main_string? ⇒ Boolean
Also known as:
main?
86
87
88
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 86
def main_string?
@run_this_command
end
|
#no_threads ⇒ Object
#
no_threads
Don’t use any threads.
#
106
107
108
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 106
def no_threads
add '-threads 0'
end
|
#overwrite_if_the_file_already_exists ⇒ Object
#
overwrite_if_the_file_already_exists
#
250
251
252
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 250
def overwrite_if_the_file_already_exists
add ' -y'
end
|
#reset ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 58
def reset
super()
@run_this_command = 'ffmpeg'
set_framerate 25
set_store_where DEFAULT_STORE_IN_THIS_DIRECTORY
end
|
#resolution? ⇒ Boolean
181
182
183
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 181
def resolution?
USE_THIS_SCREEN_RESOLUTION
end
|
#run ⇒ Object
Also known as:
start
276
277
278
279
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 276
def run
build_up_main_string
run_main_string
end
|
#run_main_string ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 72
def run_main_string
sanitize_main_string
e
e main?
e
system main?
end
|
#sameq ⇒ Object
156
157
158
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 156
def sameq
''
end
|
#sanitize_main_string ⇒ Object
#
sanitize_main_string (sanitize tag)
#
240
241
242
243
244
245
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 240
def sanitize_main_string
@run_this_command.squeeze!(' ') if @run_this_command.include? ' '
unless main?.include? store_where?
append store_where?
end
end
|
#set_duration(i) ⇒ Object
149
150
151
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 149
def set_duration(i)
add '-t '+i.to_s
end
|
#set_framerate(i) ⇒ Object
Also known as:
framerate=, framerate
#
set_framerate
In ffmpeg, “-r” equals the “-framerate” option.
#
231
232
233
234
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 231
def set_framerate(i)
i = i.to_s
@framerate = i
end
|
#size=(i = '1024x768') ⇒ Object
Also known as:
video_size, video_size=, size
#
size= (size tag)
This is -video_size which is equal to -s option in ffmpeg.
#
95
96
97
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 95
def size=(i = '1024x768')
add('-video_size '+i)
end
|
#store_here=(i) ⇒ Object
Also known as:
set_store_where
#
store_here=
This determines where to store the captured video.
#
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 115
def store_here=(i)
case i
when :pwd
i = return_pwd
end
if i.end_with? '/'
i = i.dup if i.frozen?
i << 'output.mp4'
end
@store_where = i
end
|
#store_where? ⇒ Boolean
133
134
135
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 133
def store_where?
@store_where
end
|
#video_codec=(i = 'libx264') ⇒ Object
Also known as:
vcodec
#
video_codec
Popular video codecs for ffmpeg are:
libx264
ffv1
#
194
195
196
|
# File 'lib/multimedia_paradise/video/capture_screen.rb', line 194
def video_codec=(i = 'libx264')
add " -vcodec #{i}"
end
|