diff --git a/plugins/available/v2gif.plugin.bash b/plugins/available/v2gif.plugin.bash index 744895ca..443fbb28 100644 --- a/plugins/available/v2gif.plugin.bash +++ b/plugins/available/v2gif.plugin.bash @@ -14,10 +14,11 @@ function v2gif { param '1: MOV/AVI/MP4 file name(s)' param '2: -w ; Optional: max width in pixels' param '3: -l ; Optional: extra lossy level for smaller files (80-200 make sense, needs giflossy instead of gifsicle)' - param '4: -h ; Optional: high quality using gifski (installed seperately)' + param '4: -h ; Optional: high quality using gifski (installed seperately) - overrides "--lossy" above!' param '5: -d ; Optional: delete the original video file if succeeded' param '6: -t ; Optional: Tag the result with quality stamp for comparison use' param '7: -f ; Optional: Change number of frames per second (default 10)' + param '8: -a ; Optional: Alert if resulting file is over kilobytes (default is 5000, 0 turns off)' example '$ v2gif foo.mov' example '$ v2gif foo.mov -w 600' example '$ v2gif -l 100 -d *.mp4' @@ -25,7 +26,7 @@ function v2gif { example '$ v2gif -thw 600 *.avi *.mov' # Parse the options - args=$(getopt -l "lossy:" -l "width:" -l del,delete -l high -l tag -l "fps:" -o "l:w:f:dht" -- "$@") + args=$(getopt -l "alert:" -l "lossy:" -l "width:" -l del,delete -l high -l tag -l "fps:" -o "a:l:w:f:dht" -- "$@") use_gifski="" del_after="" @@ -35,6 +36,7 @@ function v2gif { giftagopt="" giftag="" fps=10 + alert=5000 eval set -- "$args" while [ $# -ge 1 ]; do case "$1" in @@ -77,6 +79,11 @@ function v2gif { giftag="${giftag}-f$2" shift 2 ;; + -a|--alert) + # set size alert + alert="$2" + shift 2 + ;; esac done @@ -110,6 +117,15 @@ function v2gif { rm v2gif-tmp-*.png + # Checking if the file is bigger than Twitter likes and warn + if [[ $alert -gt 0 ]] ; then + out_size=$(wc --bytes < $output_file) + if [[ $out_size -gt $(( alert * 1000 )) ]] ; then + echo "$(tput setaf 3)Warning: $output_file is $((out_size/1000))kb, keeping $file even if --del requested.$(tput sgr 0)" + del_after="" + fi + fi + [[ "$del_after" = "true" ]] && rm $file done