From 899be289e6ec7d99ec2f6e25b5cb4eeab4532e9f Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Mon, 31 Jan 2022 22:38:58 +0100 Subject: [PATCH] Only optimize option --- README.md | 6 ++++++ project.clj | 2 +- src/video_optimize/core.clj | 11 +++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 64426a4..859128d 100644 --- a/README.md +++ b/README.md @@ -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). example.mp4 -> example_thumbnail.mp4 + +# Tricks + +## I just want to optimise, without resizing + +Delete from your settings Pepe `width_thumbnail`. \ No newline at end of file diff --git a/project.clj b/project.clj index 5147db0..5ed9125 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject video-optimize "1.0.3-SNAPSHOT" +(defproject video-optimize "1.0.4" :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" diff --git a/src/video_optimize/core.clj b/src/video_optimize/core.clj index 4bd42cd..c29eace 100644 --- a/src/video_optimize/core.clj +++ b/src/video_optimize/core.clj @@ -14,6 +14,7 @@ (def audio_quality_thumbnail (:audio_quality_thumbnail config)) (def path_videos (:path_videos config)) + (defn convertVideo ;; Optimize video [e] @@ -21,12 +22,14 @@ 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_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)))) (do - (prn (str "Optimizing: " path_raw)) - ;; 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" (str width_thumbnail "kb") path_thumbnail_temp) + (prn (str "Optimizing: " path_raw)) + (if (nil? width_thumbnail) + ;; 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) (prn (str "Finish: " path_thumbnail))))))