Mercurial > vba-clojure
changeset 546:36e5fa62eb3c
i believe this latest change will correct all A/V synching problems.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 27 Jun 2012 14:08:59 -0500 |
parents | 2b6cdea9bcdb |
children | b3b7a06686c4 |
files | clojure/com/aurellem/run/basic_choreo.clj clojure/com/aurellem/run/final_cut.clj |
diffstat | 2 files changed, 34 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/run/basic_choreo.clj Wed Jun 27 13:41:01 2012 -0500 1.2 +++ b/clojure/com/aurellem/run/basic_choreo.clj Wed Jun 27 14:08:59 2012 -0500 1.3 @@ -70,7 +70,7 @@ 1.4 (do-nothing 1800)))) 1.5 1.6 (def basic-render-dir 1.7 - (File. user-home "proj/vba-clojure/render/basic2")) 1.8 + (File. user-home "proj/vba-clojure/render/basic3")) 1.9 1.10 (defn basic-steps [] (first (activate-media))) 1.11
2.1 --- a/clojure/com/aurellem/run/final_cut.clj Wed Jun 27 13:41:01 2012 -0500 2.2 +++ b/clojure/com/aurellem/run/final_cut.clj Wed Jun 27 14:08:59 2012 -0500 2.3 @@ -15,22 +15,37 @@ 2.4 2.5 (def render-dir (File. user-home "proj/vba-clojure/render/test")) 2.6 2.7 -(defn force-sync 2.8 - "keep the entire movie to a certain fps" 2.9 - [fps] 2.10 - 2.11 - 2.12 - ) 2.13 - 2.14 +(defn write-move-image! [move target-file] 2.15 + (let [actual-keys (set move) 2.16 + keys [:a :b :start :select :u :d :l :r] 2.17 + button-on-name ["-size" "5x5" "xc:red"] 2.18 + button-off-name ["-size" "5x5" "xc:white"]] 2.19 + (apply 2.20 + clojure.java.shell/sh 2.21 + (flatten 2.22 + ["convert" 2.23 + "-size" "64x5" "xc:white" 2.24 + (map 2.25 + (fn [index] 2.26 + (let [position ["-geometry" 2.27 + (str "+" (* index 8) 2.28 + "+" "0") "-composite"]] 2.29 + (if (actual-keys (keys index)) 2.30 + [button-on-name position] 2.31 + [button-off-name position]))) 2.32 + (range (count keys))) 2.33 + (.getCanonicalPath target-file)])))) 2.34 2.35 (defn render-files! 2.36 ([^File target-dir initial-state moves] 2.37 (let [ram-map-dir (File. target-dir "ram-map") 2.38 frames-dir (File. target-dir "frames") 2.39 + moves-dir (File. target-dir "moves") 2.40 audio-file (File. target-dir "audio.wav") 2.41 _ (.mkdir target-dir) 2.42 _ (.mkdir ram-map-dir) 2.43 _ (.mkdir frames-dir) 2.44 + _ (.mkdir moves-dir) 2.45 wave-writer (WaveWriter. audio-file) 2.46 moves (vec moves) 2.47 desired-fps 60 2.48 @@ -62,7 +77,9 @@ 2.49 write-video! 2.50 (fn [index] 2.51 ;; write screenshot 2.52 - 2.53 + (write-move-image! 2.54 + move 2.55 + (File. moves-dir (format "%07d.png" index))) 2.56 2.57 (write-png! 2.58 @current-state 2.59 @@ -112,25 +129,13 @@ 2.60 (mapv #(.getCanonicalPath %) (next (sort (file-seq dir))))) 2.61 2.62 (defn composite-frames-command 2.63 - [screenshot ram-map target move] 2.64 - (let [actual-keys (set move) 2.65 - keys [:a :b :start :select :u :d :l :r] 2.66 - button-on-name ["-size" "5x5" "xc:red"] 2.67 - button-off-name ["-size" "5x5" "xc:white"]] 2.68 - ["convert" 2.69 - "-size" "318x276" "xc:white" 2.70 - (map 2.71 - (fn [index] 2.72 - (let [position ["-geometry" 2.73 - (str "+" (+ 30 (* index 8)) 2.74 - "+" "225") "-composite"]] 2.75 - (if (actual-keys (keys index)) 2.76 - [button-on-name position] 2.77 - [button-off-name position]))) 2.78 - (range (count keys))) 2.79 - screenshot "-geometry" "+10+10" "-composite" 2.80 - ram-map "-geometry" "+180+10" "-composite" 2.81 - target])) 2.82 + [move-image screenshot ram-map target] 2.83 + ["convert" 2.84 + "-size" "318x276" "xc:white" 2.85 + move-image "-geometry" "+30+225" "-composite" 2.86 + screenshot "-geometry" "+10+10" "-composite" 2.87 + ram-map "-geometry" "+180+10" "-composite" 2.88 + target]) 2.89 2.90 (defn generate-composite-frames! 2.91 [^File rendered-dir moves] 2.92 @@ -167,6 +172,7 @@ 2.93 "-b:v" "9000k" 2.94 "-c:a" "libvorbis" 2.95 "-c:v" "libtheora" 2.96 + "-g" "200" 2.97 (.getCanonicalPath movie)) nil)) 2.98 2.99