class MultimediaParadise::PrepareVideoLecture
Constants
- BASE_DIRECTORY
#¶ ↑
BASE_DIRECTORY
¶ ↑This is the directory we will log the output to.
On my system, this will be at:
"/Depot/Temp/MultimediaProject/video_lectures/"
#¶ ↑
- BLACK_MP4_VIDEO_FILE
#¶ ↑
BLACK_MP4_VIDEO_FILE
¶ ↑#¶ ↑
- COMMAND
#¶ ↑
COMMAND
¶ ↑#¶ ↑
- DEFAULT_URLS
#¶ ↑
DEFAULT_URLS
¶ ↑Which URLS to use by default.
#¶ ↑
- DELAY_IN_N_SECONDS
#¶ ↑
DELAY_IN_N_SECONDS
¶ ↑Specify the delay that the interval-video will use.
#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- OUTPUT_FILE
#¶ ↑
OUTPUT_FILE
¶ ↑#¶ ↑
- USE_DELAY_WHEN_MERGING_THE_VIDEO_FILES
#¶ ↑
USE_DELAY_WHEN_MERGING_THE_VIDEO_FILES
¶ ↑#¶ ↑
Public Class Methods
new( these_urls = nil, run_already = true )
click to toggle source
Public Instance Methods
create_base_directory()
click to toggle source
create_black_image()
click to toggle source
create_black_mp4_video_file()
click to toggle source
#¶ ↑
create_black_mp4_video_file
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/prepare_video_lecture.rb, line 165 def create_black_mp4_video_file output_file = BLACK_MP4_VIDEO_FILE _ = 'ffmpeg -f lavfi -i color=color=black -t '+DELAY_IN_N_SECONDS.to_s+' '+output_file system _ unless File.exist? output_file end
download_dir?()
click to toggle source
download_the_videos()
click to toggle source
#¶ ↑
download_the_videos
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/prepare_video_lecture.rb, line 225 def download_the_videos @array_downloaded_files = [] # Reset to empty always. opnn; e 'Now downloading the URLs. The download directory will be at:'+ sdir(download_dir?) urls?.each {|remote_url| opnn; e 'Now working on the URL `'+sfancy(remote_url)+'` via '+ simp(COMMAND)+'.' cmd = COMMAND+' '+remote_url # e cmd # Don't want to display it really. result = `#{cmd}` # <- This is the part where we download the file finally. File.delete('gmon.out') if File.exist? 'gmon.out' # We don't need gmon.out regex = /Merging formats into "(.*)"/ result =~ regex this_file = $1.to_s.dup if File.exist? this_file new_filename = this_file.tr(' ','_').tr("'",'').tr('-','_'). tr('(','').tr(')','').tr('&','') new_filename.squeeze! '_' opnn; rename(this_file, new_filename) this_file = new_filename # Reassign. end @array_downloaded_files << this_file opnn; e 'The final file result is: `'+sfile(this_file)+'`.' } end
enter_base_directory()
click to toggle source
merge_the_videos()
click to toggle source
#¶ ↑
merge_the_videos
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/prepare_video_lecture.rb, line 202 def merge_the_videos n_videos = @array_downloaded_files.size.to_s opnn; e 'These videos ('+simp(n_videos)+') will next be merged.' # ======================================================================= # # Sneakily insert the delay-video into the Array. # ======================================================================= # if USE_DELAY_WHEN_MERGING_THE_VIDEO_FILES _ = @array_downloaded_files array = Array.new(_.size, BLACK_MP4_VIDEO_FILE) _ = _.zip(array).flatten # ===================================================================== # # Last one should not be black, hence we remove it. # ===================================================================== # _.pop if _.last == BLACK_MP4_VIDEO_FILE @array_downloaded_files = _ end pp @array_downloaded_files ::MultimediaParadise.merge(@array_downloaded_files) end
remove_base_directory()
click to toggle source
report_everything_has_finished()
click to toggle source
#¶ ↑
report_everything_has_finished
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/prepare_video_lecture.rb, line 190 def report_everything_has_finished result = 'Everything has now finished.' if File.exist? OUTPUT_FILE result << ' It may be available here: '+ sfile((Dir.pwd+'/'+OUTPUT_FILE).squeeze('/')) end opnn; e result end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
MultimediaParadise::Base#reset
# File lib/multimedia_paradise/video/prepare_video_lecture.rb, line 102 def reset super() @array_downloaded_files = [] # ======================================================================= # # === @namespace # ======================================================================= # @namespace = NAMESPACE end
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/prepare_video_lecture.rb, line 254 def run show_welcome_message remove_base_directory create_base_directory enter_base_directory # create_black_image if USE_DELAY_WHEN_MERGING_THE_VIDEO_FILES create_black_mp4_video_file end download_the_videos merge_the_videos report_everything_has_finished end
set_work_on_these_urls(i = DEFAULT_URLS)
click to toggle source
show_welcome_message()
click to toggle source