   (fs/delete file))
 
 (defn- do-cap [cap-time-secs fps frame-dir] ""
-  (println "doing capture with total time: " cap-time-secs
-           " fps: " fps
-           " into frame dir: " frame-dir)
-  (let [in ["streamer"
-            "-o"
+  (println "INFO doing capture with total time: " cap-time-secs " fps: " fps " into frame dir: " frame-dir)
+  (let [in ["streamer" "-o"
             (str frame-dir "/000000.jpeg")
-            "-s"
-            "1920x1080"
-            "-j"
-            "100"
-            "-t"
+            "-s" "1920x1080" "-j" "100" "-t"
             (str (* (read-string fps) (read-string cap-time-secs)))
             "-r"
             fps]]
     (try
-      (println "cap in: " in)
+      (println "INFO cap sh input: " in)
       (apply sh in)
       (catch Throwable t
-        (println "cap error: " t (.getMessage t))))))
+        (println "ERROR cap error: " t)))))
 
 (defn- get-clip-number [frame-file] ""
-  (let [name (.getName frame-file)
-        stuff (Integer/parseInt (first (str/split name #"\.")))
-
-        ]
-    stuff))
+  (-> (.getName frame-file)
+      (str/split #"\.")
+      (first)
+      (Integer/parseInt)))
 
 (defn- do-clip [fps frame-dir clip-dir clip-path] ""
 
-
-
-  (let [
-        the-frames (fs/list-dir frame-dir)
+  (let [the-frames (fs/list-dir frame-dir)
         the-frames-ordered (sort-by #(get-clip-number %) the-frames)
-        with-abs(map-indexed (fn [idx itm] (hash-map :idx idx
-                                                     :file itm
-                                                     :new-file (str clip-dir "/" (format "%06d" idx) ".jpeg"))) the-frames-ordered)
-        ]
+        with-abs (map-indexed (fn [idx itm] (hash-map :idx idx
+                                                      :file itm
+                                                      :new-file (str clip-dir "/" (format "%06d" idx) ".jpeg"))) the-frames-ordered)]
     (do
-      (println "the-frames: " (count the-frames))
+      (println "INFO making clip from frame count: " (count the-frames))
       (doseq [f with-abs]
-          (move-file (:file f) (:new-file f)))
-      (println "moved to clip dir")
+        (move-file (:file f) (:new-file f)))
       (let [the-new-frames (fs/list-dir clip-dir)
-            in ["ffmpeg"
-                ;"-pattern_type glob"
-                "-r"
+            in ["ffmpeg" "-r"
                 fps
-                "-f"
-                "image2"
-                "-s"
-                "1920x1080"
-                "-i"
+                "-f" "image2" "-s" "1920x1080" "-i"
                 (str clip-dir "/%6d.jpeg")
-                "-vcodec"
-                "libx264"
-                "-crf"
-                "25"
-                "-pix_fmt"
-                "yuv420p"
-                clip-path]
-            _ (println "clip in: " in)
-            out (apply sh in)]
-        (println "did clip: " out)
+                "-vcodec" "libx264" "-crf" "25" "-pix_fmt" "yuv420p"
+                clip-path]]
+        (try
+          (println "INFO clip input: " in)
+          (apply sh in)
+          (catch Throwable t
+            (println "ERROR clip error: " t)))
         (doseq [f the-new-frames]
-            (delete-file f))
+          (delete-file f))
         (doseq [f the-frames]
-            (delete-file f))
-        (println "the new frames: " (count the-new-frames))
-        out))))
+          (delete-file f))))))
 
 (defn- clear-dir [dir]
   (fs/delete-dir dir)

      (clear-dir s3-upload-dir)

      (>!! cap-chan {:time-secs cap-time-secs
                     :fps fps
                     :frame-dir frame-dir})
      (let [clips-iterations (int
                               (/
                                (read-string cap-time-secs)
                                 (/
                                   (read-string clip-interval-ms)
                                   1000)))]


(go-loop []
  (let [data (<! clip-chan)
        {fps       :fps
         frame-dir :frame-dir
         clip-dir  :clip-dir
         clipname  :clipname} data]
    (do-clip fps frame-dir clip-dir clipname))
  (recur))

