Sha256: 945a787091ed2c72232211cfd1c68d8e4fd543618eff0cd3812e14d300c8b68d

Contents?: true

Size: 940 Bytes

Versions: 1

Compression:

Stored size: 940 Bytes

Contents

MEDIA_DIR = ENV['MEDIA_DIR']  or abort "MEDIA_DIR needed"
require 'fileutils'  # XXX

require 'ffmprb'
Ffmprb::Util::Thread.timeout = 150

VIDEO_OPT = {resolution: Ffmprb::HD_1080p, fps: 30}


# XXX
def dura_to_sec(dura_str)
  dura_str.split(':').reverse.each_with_index.reduce(0) do |sec, (ns, i)|
    sec + ns.to_i*(60**i)
  end
end

inp_path = File.join(MEDIA_DIR, 'term-samp.mov')  # XXX '/samp/term-samp.mov'
out_path = nil

FileUtils.mkdir_p (tmp_dir = File.join(MEDIA_DIR, 'present-tmp'))
begin
  Dir.chdir tmp_dir do
    warn "Working in #{tmp_dir} --"
    system "df -h #{tmp_dir}"

    out_path = File.join(MEDIA_DIR, 'present-term.mp4')
    warn "\nCut-catting to #{out_path}..."

    Ffmprb.process do
      output out_path, video: VIDEO_OPT do
        roll input(inp_path).cut to: 60 # XXX .crop(top: 0.35, bottom: 0.15, left: 0.15, right: 0.35).cut from: 10, to: 20
      end
    end
  end
ensure
  FileUtils.rm_r tmp_dir
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffmprb-0.12.1 exp/present/exp/present.rb