Fix bug exists thumbnail

This commit is contained in:
Andros Fenollosa 2020-07-13 20:15:12 +02:00
parent 34db399dd3
commit 05dba25715
4 changed files with 9 additions and 22 deletions

View File

@ -1,22 +1,7 @@
# video-optimize
A Clojure library designed to ... well, that part is up to you.
## Usage
FIXME
## License
Copyright © 2020 FIXME
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
at https://www.gnu.org/software/classpath/license.html.
``` bash
java $JVM_OPTS -cp deploy.jar clojure.main -m video-optimize.core
```

BIN
mari.mp4

Binary file not shown.

View File

@ -1,9 +1,10 @@
(defproject video-optimize "0.1.0-SNAPSHOT"
:description "FIXME: write description"
(defproject video-optimize "1.0.0-SNAPSHOT"
:description "Watcher and optimize videos"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.1"]
[hawk "0.2.11"]]
:main ^:skip-aot video-optimize.core
:aot [video-optimize.core]
:repl-options {:init-ns video-optimize.core})

View File

@ -13,11 +13,12 @@
(hawk/watch! [{:paths [PATH_VIDEOS]
:handler (fn [ctx e]
(let [path_raw (.getAbsolutePath (:file e))
is_thumbnail (re-find (re-pattern EXTENSION_THUMBNAIL) path_raw)
is_thumbnail (doall (re-find (re-pattern EXTENSION_THUMBNAIL) path_raw))
path_thumbnail (str/join (concat (drop-last (str/split path_raw #"\.")) EXTENSION_THUMBNAIL))]
(if (and (.exists (io/file path_raw)) (not is_thumbnail))
(if (and (.exists (io/file path_raw)) (not is_thumbnail) (not (.exists (io/file path_thumbnail))))
(do
(prn (str "Optimizing: " path_raw))
; Optimizing with ffmpeg
(shell/sh "ffmpeg" "-y" "-i" path_raw "-vf" "scale=600:-2" "-c:v" "libx264" "-crf" "23" "-profile:v" "high" "-pix_fmt" "yuv420p" "-color_primaries" "1" "-color_trc" "1" "-colorspace" "1" "-movflags" "+faststart" "-an" "-acodec" "aac" "-ab" "128kb" path_thumbnail)
(prn (str "Finish: " path_thumbnail))))
)