Created
February 18, 2016 08:06
-
-
Save jwarchol/96fa597dd6f73cea6293 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'json' | |
puts "Starting" | |
class String | |
def squish | |
dup.squish! | |
end | |
def squish! | |
gsub!(/\A[[:space:]]+/, '') | |
gsub!(/[[:space:]]+\z/, '') | |
gsub!(/[[:space:]]+/, ' ') | |
self | |
end | |
end | |
FileUtils.mkdir_p("attempts") | |
FileUtils.mv(Dir.glob("out_14*.mp4"), "attempts") | |
#green = "#2F6C4D" | |
green = "#3C8563" | |
#green = "#489876" | |
similarity = 0.12 | |
blend = 0.11 | |
width = 3111 | |
height = 1944 | |
left = 1450 | |
top = 800 | |
filters = [] | |
#filters << "[1:v]colorkey=0x418260:0.01:0.0[gs0]" | |
#filters << "[gs0]colorkey=#{green.sub("#", "0x")}:#{similarity}:#{blend}[gs]" | |
#filters << "[1:v][2:v]overlay[masked]" | |
filters << "[1:v]colorkey=#{green.sub("#", "0x")}:#{similarity}:#{blend}[gs]" | |
filters << "[gs]crop=#{width}:#{height}:#{left}:#{top}[crp]" | |
filters << "[crp]scale=-1:1000[sc]" | |
filters << "[0:v][sc]overlay[out]" | |
#s = `http post http://logo-booth-camera.ted.com:4567/capture/1` | |
#image_url = JSON.parse(s)['image'] | |
note = { | |
colorkey: { | |
green: green, | |
blend: blend, | |
similarity: similarity | |
}, | |
crop: { | |
width: width, | |
height: height, | |
top: top, | |
left: left | |
}, | |
filters: filters | |
} | |
#-i black.png | |
cmd = %| | |
ffmpeg | |
-f lavfi | |
-i "movie=filename=1.mp4" | |
-loop 1 | |
-r 2 | |
-i logo_booth_%d.jpg | |
-i mask.png | |
-filter_complex "#{filters.join(";")}" | |
-metadata comment='#{note.to_json}' | |
-metadata author="Joshua" | |
-map "[out]" | |
-an | |
-y | |
-t 5 | |
out_#{Time.now.to_i}.mp4 | |
|.squish | |
puts cmd | |
system cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment