Only optimize option

This commit is contained in:
Andros Fenollosa 2022-01-31 22:38:58 +01:00
parent b6b8e06a11
commit 899be289e6
3 changed files with 14 additions and 5 deletions

View File

@ -59,3 +59,9 @@ java $JVM_OPTS -cp video-optimize-{version}-SNAPSHOT-standalone.jar clojure.main
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 example.mp4 -> example_thumbnail.mp4
# Tricks
## I just want to optimise, without resizing
Delete from your settings Pepe `width_thumbnail`.

View File

@ -1,4 +1,4 @@
(defproject video-optimize "1.0.3-SNAPSHOT" (defproject video-optimize "1.0.4"
: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

@ -14,6 +14,7 @@
(def audio_quality_thumbnail (:audio_quality_thumbnail config)) (def audio_quality_thumbnail (:audio_quality_thumbnail config))
(def path_videos (:path_videos config)) (def path_videos (:path_videos config))
(defn convertVideo (defn convertVideo
;; Optimize video ;; Optimize video
[e] [e]
@ -21,12 +22,14 @@
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 (str/join "." ( drop-last (str/split path_raw #"\."))) extension_thumbnail) path_thumbnail (str (str/join "." ( drop-last (str/split path_raw #"\."))) extension_thumbnail)
path_thumbnail_temp (str "/tmp/" (last (str/split path_thumbnail #"\/")))] path_thumbnail_temp (str "/tmp/" (last (str/split path_thumbnail #"\/")))]
(prn 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 (if (nil? width_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) ;; Not width, not scale
(shell/sh "ffmpeg" "-y" "-i" path_raw "-c:v" "libx264" "-c:a" "aac" "-ab" (str audio_quality_thumbnail) "-strict" "-2" path_thumbnail_temp)
;; With width, scale
(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" "-c:a" "aac" "-ab" (str audio_quality_thumbnail) path_thumbnail_temp))
(shell/sh "mv" path_thumbnail_temp path_thumbnail) (shell/sh "mv" path_thumbnail_temp path_thumbnail)
(prn (str "Finish: " path_thumbnail)))))) (prn (str "Finish: " path_thumbnail))))))