9 Commits
1.0.0 ... 1.0.2

Author SHA1 Message Date
e06d5f1f24 Add temp folder and config quality audio 2020-07-15 11:28:31 +02:00
0763285918 Update project.clj 2020-07-14 11:39:54 +02:00
74a1083c32 Update README.md 2020-07-14 11:39:38 +02:00
86bd63f37c Merge pull request #1 from josesanch/master
Add needed gen-class
2020-07-14 11:28:07 +02:00
1be8149a68 Update README.md 2020-07-14 11:25:10 +02:00
c933503b16 Add needed gen-class 2020-07-14 11:24:19 +02:00
9448c34702 Update README.md 2020-07-14 09:39:29 +02:00
a024cd4cd8 Update README.md 2020-07-14 09:38:42 +02:00
e7b010c236 Update README.md 2020-07-14 00:07:50 +02:00
5 changed files with 44 additions and 17 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ pom.xml.asc
.hgignore .hgignore
.hg/ .hg/
videos/ videos/
.DS_Store

View File

@ -1,32 +1,55 @@
# Usage # Install
1) Create `config.yaml`. 1) Install Java.
Debian/Ubuntu
``` bash
sudo apt install default-jdk
```
Mac OS
``` bash
brew install openjdk
```
2) Create `config.yaml`.
``` bash ``` bash
extension_thumbnail: "_thumbnail.mp4" extension_thumbnail: "_thumbnail.mp4"
width_thumbnail: 600 width_thumbnail: 600
path_videos: "videos" path_videos: "videos"
audio_quality_thumbnail: 128
``` ```
2) Make folder `path_videos`. 3) Make folder `path_videos`.
``` bash ``` bash
mkdir videos mkdir videos
``` ```
3) Install `ffmpeg`. 4) Install `ffmpeg`.
4) Download the latest version (`video-optimize-{version}-standalone.jar`). 5) Download the latest version (`video-optimize-{version}-SNAPSHOT-standalone.jar`).
https://github.com/tanrax/auto-video-thumbnail/releases https://github.com/tanrax/auto-video-thumbnail/releases
5) Now you can execute. 6) Now you can execute.
``` bash ``` bash
java $JVM_OPTS -cp video-optimize-{version}-standalone.jar clojure.main -m video-optimize.core java -jar video-optimize-{version}-SNAPSHOT-standalone.jar
``` ```
6) Leave videos. or
``` bash
java $JVM_OPTS -cp video-optimize-{version}-SNAPSHOT-standalone.jar clojure.main -m video-optimize.core
```
7) Leave videos in folder `videos`.
Everything you leave in the videos folder will be optimized for web with the specified resolution (600px in this example). Everything you leave in the videos folder will be optimized for web with the specified resolution (600px in this example).
example.mp4 -> example_thumbnail.mp4

View File

@ -1,3 +1,4 @@
extension_thumbnail: "_thumbnail.mp4" extension_thumbnail: "_thumbnail.mp4"
width_thumbnail: 600 width_thumbnail: 600
path_videos: "videos" path_videos: "videos"
audio_quality_thumbnail: 128

View File

@ -1,4 +1,4 @@
(defproject video-optimize "1.0.0-SNAPSHOT" (defproject video-optimize "1.0.2-SNAPSHOT"
:description "Watcher and optimize videos" :description "Watcher and optimize videos"
:url "http://example.com/FIXME" :url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"

View File

@ -1,4 +1,5 @@
(ns video-optimize.core (ns video-optimize.core
(:gen-class)
(:require (:require
[clojure.java.io :as io] [clojure.java.io :as io]
[clojure.string :as str] [clojure.string :as str]
@ -10,6 +11,7 @@
(def config (yaml/parse-string (slurp "config.yaml"))) (def config (yaml/parse-string (slurp "config.yaml")))
(def extension_thumbnail (:extension_thumbnail config)) (def extension_thumbnail (:extension_thumbnail config))
(def width_thumbnail (:width_thumbnail config)) (def width_thumbnail (:width_thumbnail config))
(def audio_quality_thumbnail (:audio_quality_thumbnail config))
(def path_videos (:path_videos config)) (def path_videos (:path_videos config))
(defn -main [& args] (defn -main [& args]
@ -18,13 +20,13 @@
:handler (fn [ctx e] :handler (fn [ctx e]
(let [path_raw (.getAbsolutePath (:file e)) (let [path_raw (.getAbsolutePath (:file e))
is_thumbnail (doall (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))] path_thumbnail (str/join (concat (drop-last (str/split path_raw #"\.")) extension_thumbnail))
path_thumbnail_temp (str "/tmp/" (last (str/split path_thumbnail #"\/")))]
(if (and (.exists (io/file path_raw)) (not is_thumbnail) (not (.exists (io/file path_thumbnail)))) (if (and (.exists (io/file path_raw)) (not is_thumbnail) (not (.exists (io/file path_thumbnail))))
(do (do
(prn (str "Optimizing: " path_raw)) (prn (str "Optimizing: " path_raw))
;; Optimizing with ffmpeg ;; Optimizing with ffmpeg
(shell/sh "ffmpeg" "-y" "-i" path_raw "-vf" (str "scale=" width_thumbnail ":-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) (shell/sh "ffmpeg" "-y" "-i" path_raw "-vf" (str "scale=" width_thumbnail ":-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" (str width_thumbnail "kb") path_thumbnail_temp)
(prn (str "Finish: " path_thumbnail)))) (shell/sh "mv" path_thumbnail_temp path_thumbnail)
) (prn (str "Finish: " path_thumbnail))))))}])
)}])
(println "Running: Feed me!")) (println "Running: Feed me!"))