Class: MCutter::CLI

Inherits:
Thor
  • Object
show all
Includes:
FileUtils, Thor::Actions
Defined in:
lib/mcutter/cli.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



36
37
38
# File 'lib/mcutter/cli.rb', line 36

def method_missing(name, *args)
  $stderr.puts 'Could not find command "%s".' % name; exit 1
end

Instance Method Details

#cutObject



15
16
17
18
19
20
21
# File 'lib/mcutter/cli.rb', line 15

def cut
  open('timeline.txt').each do |line|
    file, starts_seconds, ends_seconds, ofile = *line.split(" ", 4)
    duration_seconds = (ends_seconds.to_sec - starts_seconds.to_sec).to_hh_mm_ss
    run "ffmpeg -i #{file} -threads 3 -y -vcodec copy -ss #{starts_seconds} -t #{duration_seconds} #{ofile}"
  end
end

#initObject



24
25
26
27
28
# File 'lib/mcutter/cli.rb', line 24

def init
  mkdir_p "src"
  mkdir_p "out"
  touch "timeline.txt"
end