class MultimediaParadise::Video::VideoInformation
Constants
- AUDIO_STREAMS
#¶ ↑
AUDIO_STREAMS
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- SHALL_WE_DEBUG
#¶ ↑
SHALL_WE_DEBUG
¶ ↑#¶ ↑
- VIDEO_STREAMS
#¶ ↑
VIDEO_STREAMS
¶ ↑The registered videostreams come here.
#¶ ↑
Public Class Methods
Public Instance Methods
audio?()
click to toggle source
#¶ ↑
audio?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 145 def audio? @audio end
Also aliased as: audio
be_verbose?()
click to toggle source
bitrate?()
click to toggle source
data?()
click to toggle source
#¶ ↑
data?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 218 def data? @data end
Also aliased as: data
decompose(i)
click to toggle source
#¶ ↑
decompose¶ ↑
The input will hold all information.
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 376 def decompose(i) i = i.split(N) if SHALL_WE_DEBUG opnn; e 'The user wants to debug, so we will output the information' opnn; e 'that is to be decomposed:' pp i end grab_all_streams = i.select {|entry| entry.strip.include? 'Stream #' # Grab all video and audio streams. } set_audio(grab_all_streams) set_video(grab_all_streams) set_resolution(grab_all_streams) end
determine_duration_of_the_file()
click to toggle source
#¶ ↑
determine_duration_of_the_file
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 308 def determine_duration_of_the_file use_this_regex = /Duration: (\d{1,2}:\d{1,2}:\d{1,2}.\d{1,2})/ # See: http://rubular.com/r/NYoZ9GMryH input_stream? =~ use_this_regex set_duration($1.to_s.dup) end
duration?()
click to toggle source
files?()
click to toggle source
input_stream?()
click to toggle source
inspect_this_file_via_ffmpeg( the_file = files?.first )
click to toggle source
name?()
click to toggle source
opnn()
click to toggle source
populate_main_data()
click to toggle source
report_audio_bitrate()
click to toggle source
report_audio_stream()
click to toggle source
#¶ ↑
report_audio_stream
¶ ↑
We try to report which audio stream we have, e. g. “.mp3”.
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 227 def report_audio_stream if audio? opnn; e 'The audio stream is `'+sfancy(audio?)+'`.' if audio?.end_with? 'mp3' # Ok we have a .mp3 file. Report the audio-bitrate next. report_audio_bitrate end else opnn; e 'No audio stream could be found.' end end
report_the_duration()
click to toggle source
#¶ ↑
report_the_duration
¶ ↑
This method will report the duration of that particular multimedia file.
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 362 def report_the_duration duration = duration? opnn; e 'The duration of this file is `'+ sfancy(duration.to_s)+'` seconds. '\ '('+seagreen( to_hh_mm_ss(duration) )+')' end
report_the_name_of_the_file()
click to toggle source
report_the_resolution()
click to toggle source
report_video_stream()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
MultimediaParadise::Base#reset
# File lib/multimedia_paradise/video/video_information.rb, line 74 def reset super() set_audio # Set it to empty first. # ======================================================================= # # === @video # ======================================================================= # @video = nil # ======================================================================= # # === @be_verbose # ======================================================================= # @be_verbose = true # ======================================================================= # # === @data # # This Array will hold video and audio. # ======================================================================= # @data = [] # ======================================================================= # # === @report_the_namespace # ======================================================================= # @report_the_namespace = true # ======================================================================= # # === resolution # # This will carry the video result, such as: 1280x720 # ======================================================================= # @resolution = nil set_duration nil # Initialize it to nil specifically. end
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 413 def run files?.each {|the_file| if File.exist? the_file _ = inspect_this_file_via_ffmpeg(the_file) decompose(_) populate_main_data determine_duration_of_the_file else if be_verbose? opnn; e 'File at `'+sfile(the_file)+'` does not exist.' end end } end
set_audio(i = nil)
click to toggle source
#¶ ↑
set_audio
(audio tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 159 def set_audio(i = nil) if i.is_a? Array i = i.select {|entry| entry.include? 'Audio:' } set_hertz(i) if i.include? ' Hz' i = i.first unless i.empty? end if i i = AUDIO_STREAMS.find { |s| i.include?(s.to_s) } i = nil if i.is_a? Array # Then it must be empty. end @audio = i end
set_bitrate(i)
click to toggle source
set_duration(i = nil)
click to toggle source
set_files(i = '')
click to toggle source
set_hertz(i)
click to toggle source
set_resolution(i)
click to toggle source
#¶ ↑
set_resolution
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 394 def set_resolution(i) if i if i.is_a? Array selection = i.select {|entry| entry.include?('Video: ') }.first if selection.include? 'x' i = selection.scan( /\d{2,4}x\d{2,4}/ ).flatten.first.to_s.strip end end @resolution = i end end
set_video(i)
click to toggle source
#¶ ↑
set_video
(video tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 200 def set_video(i) if i.is_a? Array i = i.select {|entry| entry.include? 'Video:' } i = i.first unless i.empty? end result = VIDEO_STREAMS.find { |s| i.include?(s) } # ======================================================================= # # Handle XVID next: # ======================================================================= # if result == 'mpeg4' and i.include?('XVID') result << ' (XVID)' end @video = result end
verbose_report(report_the_namespace = true)
click to toggle source
#¶ ↑
verbose_report
¶ ↑
This method will report the name, the video stream and the audio stream.
#¶ ↑
# File lib/multimedia_paradise/video/video_information.rb, line 327 def verbose_report(report_the_namespace = true) case report_the_namespace when :do_not_report_the_namespace @report_the_namespace = false end report_the_name_of_the_file report_video_stream report_audio_stream report_the_duration if @duration end
Also aliased as: report