Module: Ktsh

Defined in:
lib/ktsh.rb,
lib/ktsh/version.rb

Defined Under Namespace

Classes: Meta

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.create(video, horizontal: 8, vertical: 6, width: 2560, padding: 2) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/ktsh.rb', line 73

def create(video, horizontal: 8, vertical: 6, width: 2560, padding: 2)
  start = Time.now
  lock = Mutex.new
  stop = false
  Thread.new{ loop{ break if lock.synchronize{stop}; print "\r#{start.strftime('%T')}~#{Time.now.strftime('%T')} #{File.basename(video)}"; sleep 1 } }

  sample_width = (width - ((horizontal - 1) * padding) - 4) / horizontal
  meta = Meta.new(video, horizontal * vertical, sample_width)
  command = %Q{ffmpeg -pattern_type glob -i "#{meta.tmpdir}/*.jpg" -filter_complex "tile=#{horizontal}x#{vertical}:padding=#{padding}:color=white,pad=iw+4:ih+102:2:100:white,drawtext=textfile='#{meta.info_file}':fontsize=18:fontcolor=black:x=2:y=2,format=yuv420p" -q:v 2 "#{video}.jpg" 2>/dev/null}
  system(command)

  lock.synchronize{stop = true}
  puts
end