comparison clojure/com/aurellem/run/final_cut.clj @ 547:b3b7a06686c4

all synching issues resolved.
author Robert McIntyre <rlm@mit.edu>
date Wed, 27 Jun 2012 19:38:13 -0500
parents 36e5fa62eb3c
children 6ce1d5fd4911
comparison
equal deleted inserted replaced
546:36e5fa62eb3c 547:b3b7a06686c4
47 _ (.mkdir frames-dir) 47 _ (.mkdir frames-dir)
48 _ (.mkdir moves-dir) 48 _ (.mkdir moves-dir)
49 wave-writer (WaveWriter. audio-file) 49 wave-writer (WaveWriter. audio-file)
50 moves (vec moves) 50 moves (vec moves)
51 desired-fps 60 51 desired-fps 60
52 seconds-per-frame (/ 1.0 desired-fps) 52 seconds-per-frame (/ 1.0 desired-fps)]
53
54 ]
55 (set-state! initial-state) 53 (set-state! initial-state)
56 ;; clear sound buffer 54 ;; clear sound buffer
57 (sound-bytes) 55 (sound-bytes)
58 (try 56 (try
59 (dorun 57 (dorun
136 screenshot "-geometry" "+10+10" "-composite" 134 screenshot "-geometry" "+10+10" "-composite"
137 ram-map "-geometry" "+180+10" "-composite" 135 ram-map "-geometry" "+180+10" "-composite"
138 target]) 136 target])
139 137
140 (defn generate-composite-frames! 138 (defn generate-composite-frames!
141 [^File rendered-dir moves] 139 [^File rendered-dir]
142 (let [final-frames (File. rendered-dir "final") 140 (let [final-frames (File. rendered-dir "final")
143 _ (.mkdir final-frames) 141 _ (.mkdir final-frames)
142 move-images (file-names (File. rendered-dir "moves"))
144 screenshots (file-names (File. rendered-dir "frames")) 143 screenshots (file-names (File. rendered-dir "frames"))
145 ram-maps (file-names (File. rendered-dir "ram-map")) 144 ram-maps (file-names (File. rendered-dir "ram-map"))
146 targets (map #(.getCanonicalPath 145 targets (map #(.getCanonicalPath
147 (File. final-frames (format "%07d.bmp" %))) 146 (File. final-frames (format "%07d.bmp" %)))
148 (range (count screenshots)))] 147 (range (count screenshots)))]
150 (map 149 (map
151 (comp 150 (comp
152 (partial apply clojure.java.shell/sh) 151 (partial apply clojure.java.shell/sh)
153 flatten 152 flatten
154 (partial apply composite-frames-command) 153 (partial apply composite-frames-command)
155 (fn [a b c d] (println c) [a b c d])) 154 (fn [a b c d] (println d) [a b c d]))
156 screenshots ram-maps targets moves)))) 155 move-images screenshots ram-maps targets))))
157 156
158 157
159 (defn final-cut! [^File render-dir] 158 (defn final-cut! [^File render-dir]
160 (let [movie (File. render-dir "final.ogg") 159 (let [movie (File. render-dir "final.ogg")
161 final-audio (File. render-dir "final.wav") 160 final-audio (File. render-dir "final.wav")
162 final (File. render-dir "final")] 161 final (File. render-dir "final")]
163 (.delete movie) 162 (.delete movie)
163 (.delete final-audio)
164 (clojure.java.shell/sh 164 (clojure.java.shell/sh
165 "sox" (.getCanonicalPath (File. render-dir "audio.wav")) 165 "sox" (.getCanonicalPath (File. render-dir "audio.wav"))
166 (.getCanonicalPath final-audio)) 166 (.getCanonicalPath final-audio))
167 (clojure.java.shell/sh 167 (clojure.java.shell/sh
168 "ffmpeg" "-r" "60" ;; maybe 59.7 ???! 168 "ffmpeg" "-r" "60" ;; maybe 59.7 ???!
169 "-i" (str (.getCanonicalPath final) "/" "%07d.bmp") 169 "-i" (str (.getCanonicalPath final) "/" "%07d.bmp")
170 "-i" (.getCanonicalPath final-audio) 170 "-i" (.getCanonicalPath final-audio)
171 "-b:a" "128k" 171 "-b:a" "128k"
172 "-b:v" "9000k" 172 "-b:v" "9000k"
173 "-c:a" "libvorbis" 173 "-c:a" "libvorbis"
174 "-c:v" "libtheora" 174 "-f" "webm"
175 "-g" "200" 175 "-g" "200"
176 (.getCanonicalPath movie)) nil)) 176 (.getCanonicalPath movie)) nil))
177 177
178 178
179 (comment 179 (comment