@edvakfさんにスクリーンショット撮ると面白いよーと教えていただいたので、以下の記事を参考にRubyでコード書いてみた。
Macのスクリーンショットで1日の作業を記録して動画で振り返り – 西尾泰和のはてなダイアリー
screencaptureというMacに初めから入っているコマンドを使うとスクリーンキャプチャが撮れるらしい。
さらに、ffmpegを断片の画像たちを動画に変換する。
これで一日の最後に自分がどうゆう作業をしていたのがダイジェスト(走馬灯)のように確認できて面白い。
さらにiSightで自分の顔を撮っても面白そう。
スクリーンキャプチャを撮るサンプルコード
class Capture attr_accessor :path @@INTERVAL = 30 def initialize(path="~/") @path = path end public def capture Dir.glob(@path + "**/*") do | f | p f File.delete(f) end 0.upto(0/(0.0)) do | count | filename = @path + now() + "-%08d.png"%[count] save(filename) sleep(@@INTERVAL) end end private def save(filename) system("screencapture -x #{filename}") end def now Time.now.strftime("%Y-%m-%d") end end capture = Capture.new("/Users/hisamatsu/capture/image/") capture.capture
gist
画像から動画を作るサンプルコード
事前に
brew install ffmpeg
しとくこと。
class Movie attr_accessor :image_path attr_accessor :movie_path def initialize(image_path="~/", movie_path="~/") @image_path = image_path @movie_path = movie_path end public def capture filename = movie_path + now() + ".avi" save(filename) end private def save(filename) command = "ffmpeg -y -f image2 -r 5 -i #{@image_path}#{now()}-%08d.png -s 720x450 #{filename}" system(command) end def now Time.now.strftime("%Y-%m-%d") end end capture = Movie.new("/Users/hisamatsu/capture/image/", "/Users/hisamatsu/capture/movie/") capture.capture
gist
aviファイルなのでVLCとかで開くとよいかと思います。
たのしいRuby 第3版
posted with amazlet at 13.01.25
高橋 征義 後藤 裕蔵
ソフトバンククリエイティブ
売り上げランキング: 21,205
ソフトバンククリエイティブ
売り上げランキング: 21,205