Class: Ace::Demo::CLI::Commands::Retime

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/demo/cli/commands/retime.rb

Instance Method Summary collapse

Instance Method Details

#call(file:, **options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ace/demo/cli/commands/retime.rb', line 21

def call(file:, **options)
  raise Ace::Support::Cli::Error, "Playback speed is required" unless options[:playback_speed]

  retimer = Molecules::MediaRetimer.new
  result = retimer.retime(
    input_path: File.expand_path(file, Dir.pwd),
    speed: options[:playback_speed],
    output_path: options[:output] && File.expand_path(options[:output], Dir.pwd),
    dry_run: options[:dry_run]
  )

  if result[:dry_run]
    puts "[dry-run] Would retime: #{result[:input_path]}"
    puts "[dry-run] Speed: #{result[:speed]}"
    puts "[dry-run] Output: #{result[:output_path]}"
  else
    puts "Retimed: #{result[:output_path]} (#{result[:speed]})"
  end
rescue FfmpegNotFoundError, MediaRetimeError, ArgumentError => e
  raise Ace::Support::Cli::Error, e.message
end