class MultimediaParadise::AnalyseMultimediaFile
Constants
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
new( commandline_arguments = nil, run_already = true )
click to toggle source
Public Instance Methods
analyze_this_result(i)
click to toggle source
#¶ ↑
analyze_this_result
¶ ↑
This method will analyse the result that “ffmpeg -i” gave us.
#¶ ↑
# File lib/multimedia_paradise/multimedia/analyse_multimedia_file.rb, line 97 def analyze_this_result(i) # debug_this(i) # This can be enabled/disabled. if i.include? 'encoder :' i =~ /encoder : (.+)$/ @encoder = $1.to_s.dup e 'The encoder is: '.ljust(@left_pad_n_times)+lightgreen(@encoder) end # ======================================================================= # # === Duration # ======================================================================= # if i.include? 'Duration: ' i =~ /Duration: ([0-9:.]{2,12}),/ # See: https://rubular.com/r/Rq5lAuQnJUfiZd @duration = $1.to_s.dup n_seconds = return_this_duration_in_seconds(@duration) e 'The duration is: '.ljust(@left_pad_n_times)+ lightgreen(@duration)+' ('+ olive(n_seconds.to_s+' seconds')+ ')' end # ======================================================================= # # === Stream #0:0: # ======================================================================= # if i.include? 'Stream #0:0:' if i.include? 'x' results = i.scan(/ (\d{1,3})x(\d{1,3}) /) e 'Video resolution is: '.ljust(@left_pad_n_times)+ lightgreen( results.flatten.join('x').to_s ) end # if i.include? 'Video:' # e 'Codec: '.ljust(@left_pad_n_times)+ # 'mpeg4' # end end if i.include? 'ENCODER ' # ===================================================================== # # ENCODER : Lavf58.29.100 # ===================================================================== # scanned_result = i.scan(/ENCODER\s*: (.+)/).flatten.first e 'The encoder is: '.ljust(@left_pad_n_times)+ lightgreen(scanned_result) end if i.include? ': Audio: mp3, ' e 'The file includes an audio stream '\ '('+royalblue('mp3 format')+').' end end
debug_this(i)
click to toggle source
opnn(&block)
click to toggle source
process_the_input()
click to toggle source
#¶ ↑
process_the_input
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/multimedia/analyse_multimedia_file.rb, line 63 def process_the_input @commandline_arguments.each {|this_file| if is_a_multimedia_file?(this_file) opnn { :no_colon } e e e 'The multimedia file '+sfile(this_file)+' will be analysed next,' e "via #{orange('ffmpeg')}." e cmd = "ffmpeg -i #{this_file} 2>&1" e slateblue(" #{cmd}") e result = `#{cmd}` analyze_this_result(result) else opnn; e sfile(this_file)+' can not be analysed as it is not a (registered)' opnn; e 'audio/video (multimedia) file.' end } end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
MultimediaParadise::Base#reset
# File lib/multimedia_paradise/multimedia/analyse_multimedia_file.rb, line 45 def reset super() # ======================================================================= # # === @left_pad_n_times # ======================================================================= # @left_pad_n_times = 25 end
return_this_duration_in_seconds( i = '00:03:52.15' )
click to toggle source
#¶ ↑
return_this_duration_in_seconds
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/multimedia/analyse_multimedia_file.rb, line 149 def return_this_duration_in_seconds( i = '00:03:52.15' ) result = 0.0 if i.include? ':' splitted = i.split(':') result += (splitted[0].to_f * 60 * 60) result += (splitted[1].to_f * 60) # These is the entry for minutes. result += splitted[2].to_f end result end