Class: Jwthumbs::Movie
- Inherits:
-
Object
- Object
- Jwthumbs::Movie
- Defined in:
- lib/movie.rb
Instance Attribute Summary collapse
-
#clear_files ⇒ Object
Returns the value of attribute clear_files.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#gallery_mode_on ⇒ Object
Returns the value of attribute gallery_mode_on.
-
#outdir ⇒ Object
Returns the value of attribute outdir.
-
#seconds_between ⇒ Object
Returns the value of attribute seconds_between.
-
#spritefile ⇒ Object
Returns the value of attribute spritefile.
-
#thumb_width ⇒ Object
Returns the value of attribute thumb_width.
-
#vttfile ⇒ Object
Returns the value of attribute vttfile.
Instance Method Summary collapse
- #create_thumbs! ⇒ Object
-
#initialize(file_path = nil, options = {}) ⇒ Movie
constructor
A new instance of Movie.
Constructor Details
#initialize(file_path = nil, options = {}) ⇒ Movie
Returns a new instance of Movie.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/movie.rb', line 10 def initialize(file_path=nil, ={}) raise Errno::ENOENT, "the file '#{file_path}' does not exist" unless File.exists?(file_path) command = "ffprobe -i #{file_path} -show_format | grep duration" output = Open3.popen3(command) { |stdin, stdout, stderr| stderr.read } output[/Duration: (\d{2}):(\d{2}):(\d{2}\.\d{2})/] @duration = ($1.to_i*60*60) + ($2.to_i*60) + $3.to_f @file_path = file_path @clear_files = [:clear_files] ||= true @seconds_between = [:seconds_between] ||= @duration.to_i/10 @thumb_width = [:thumb_width] ||= 100 @spritefile = [:spritefile] ||= "#{File.basename(@file_path, File.extname(@file_path))}_sprite.jpg" @vttfile_name = [:vttfile_name] ||= "thumbs.vtt" @outdir = [:thumb_outdir] ||= "output/thumbs_#{Time.now.to_i.to_s}" @vttfile = File.basename(@file_path, File.extname(@file_path))+"_"+@vttfile_name @gallery_mode_on = [:gallery_mode_on] ||= false end |
Instance Attribute Details
#clear_files ⇒ Object
Returns the value of attribute clear_files.
8 9 10 |
# File 'lib/movie.rb', line 8 def clear_files @clear_files end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
7 8 9 |
# File 'lib/movie.rb', line 7 def duration @duration end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
7 8 9 |
# File 'lib/movie.rb', line 7 def file_path @file_path end |
#gallery_mode_on ⇒ Object
Returns the value of attribute gallery_mode_on.
8 9 10 |
# File 'lib/movie.rb', line 8 def gallery_mode_on @gallery_mode_on end |
#outdir ⇒ Object
Returns the value of attribute outdir.
8 9 10 |
# File 'lib/movie.rb', line 8 def outdir @outdir end |
#seconds_between ⇒ Object
Returns the value of attribute seconds_between.
8 9 10 |
# File 'lib/movie.rb', line 8 def seconds_between @seconds_between end |
#spritefile ⇒ Object
Returns the value of attribute spritefile.
8 9 10 |
# File 'lib/movie.rb', line 8 def spritefile @spritefile end |
#thumb_width ⇒ Object
Returns the value of attribute thumb_width.
8 9 10 |
# File 'lib/movie.rb', line 8 def thumb_width @thumb_width end |
#vttfile ⇒ Object
Returns the value of attribute vttfile.
8 9 10 |
# File 'lib/movie.rb', line 8 def vttfile @vttfile end |