Minor cleanup
This commit is contained in:
@@ -99,6 +99,8 @@ means less visible pattern at the cost of more banding.
|
||||
* As APNG does not support multiple input palettes, palettegen (-m) will
|
||||
fall back to using diff mode if single mode is selected.
|
||||
* For WEBP lossy (-l) encoding, the quality parameter is mandatory.
|
||||
* Since FFmpeg can convert between any format, it's also possible to
|
||||
convert between for instance GIF to WEBP, although frame rates might be off.
|
||||
* This tool uses ffmpeg, you can download that here: [FFmpeg](https://www.ffmpeg.org/)
|
||||
* You can download this fork from here: [Pathduck/vid2ani](https://github.com/Pathduck/vid2ani)
|
||||
* You can download the original release here: [MDHEXT/video2gif](https://github.com/MDHEXT/video2gif)<br>
|
||||
|
||||
+19
-23
@@ -17,20 +17,23 @@ SET "YELLOW=[33m"
|
||||
SET "BLUE=[94m"
|
||||
SET "CYAN=[96m"
|
||||
|
||||
:: Clearing all variables
|
||||
SET "scale="
|
||||
SET "fps="
|
||||
SET "mode="
|
||||
SET "dither="
|
||||
:: Clearing vars and setting defaults
|
||||
SET "fps=15"
|
||||
SET "mode=1"
|
||||
SET "dither=0"
|
||||
SET "scale=-1"
|
||||
SET "filetype=gif"
|
||||
SET "webp_lossy="
|
||||
SET "webp_lossy_def=75"
|
||||
SET "loglevel=error"
|
||||
SET "bayerscale="
|
||||
SET "filetype="
|
||||
SET "colormax="
|
||||
SET "start_time="
|
||||
SET "end_time="
|
||||
SET "webp_lossy="
|
||||
SET "colormax="
|
||||
SET "version="
|
||||
SET "build="
|
||||
SET "loglevel="
|
||||
SET "errorswitch="
|
||||
SET "picswitch="
|
||||
|
||||
:: Assign input and output
|
||||
SET input="%~1"
|
||||
@@ -67,29 +70,22 @@ IF NOT "%~1" =="" (
|
||||
IF "%~1" =="-s" SET "start_time=%~2" & SHIFT
|
||||
IF "%~1" =="-e" SET "end_time=%~2" & SHIFT
|
||||
IF "%~1" =="-c" SET "colormax=%~2" & SHIFT
|
||||
IF "%~1" =="-l" SET "webp_lossy=%~2" & SHIFT
|
||||
:: IF "%~1" =="-l" SET "webp_lossy=%~2" & SHIFT
|
||||
IF "%~1" =="-l" (IF "%2" == "" ( SET "webp_lossy=%webp_lossy_def%"
|
||||
) ELSE IF 1%2 NEQ +1%~2 ( SET "webp_lossy=%webp_lossy_def%"
|
||||
) ELSE ( SET "webp_lossy=%~2" & SHIFT )
|
||||
)
|
||||
IF "%~1" =="-v" SET "loglevel=%~2" & SHIFT
|
||||
IF "%~1" =="-k" SET "errorswitch=1"
|
||||
IF "%~1" =="-p" SET "picswitch=1"
|
||||
SHIFT & GOTO :varin
|
||||
)
|
||||
GOTO :help_check_2
|
||||
|
||||
:help_check_2
|
||||
:: Noob proofing the script to prevent it from breaking should critical settings not be defined
|
||||
IF NOT DEFINED scale SET "scale=-1"
|
||||
IF NOT DEFINED fps SET "fps=15"
|
||||
IF NOT DEFINED mode SET "mode=1"
|
||||
IF NOT DEFINED dither SET "dither=0"
|
||||
IF NOT DEFINED filetype SET "filetype=gif"
|
||||
IF NOT DEFINED loglevel SET "loglevel=error"
|
||||
|
||||
GOTO :safchek
|
||||
|
||||
:safchek
|
||||
:: Setting a clear range of acceptable setting values and noob proofing bayerscale
|
||||
|
||||
:: Output file type
|
||||
:: Validate output file extension
|
||||
echo %filetype% | findstr /r "\<gif\> \<png\> \<apng\> \<webp\>" >nul
|
||||
IF %errorlevel% NEQ 0 (
|
||||
ECHO %RED%Not a valid file type: %filetype%%OFF%
|
||||
@@ -289,7 +285,7 @@ IF NOT EXIST "%output%" (
|
||||
GOTO :cleanup
|
||||
)
|
||||
|
||||
:: Starting default Photo Viewer
|
||||
:: Open output file if picswitch is set
|
||||
IF DEFINED picswitch START "" "%output%"
|
||||
|
||||
:cleanup
|
||||
|
||||
+11
-8
@@ -7,7 +7,7 @@
|
||||
# License: GNU General Public License v3.0 (GPLv3)
|
||||
|
||||
# Enable error handling
|
||||
set -euo pipefail
|
||||
# set -euo pipefail
|
||||
|
||||
### Start Main ###
|
||||
main() {
|
||||
@@ -20,19 +20,20 @@ YELLOW=$(tput setaf 11)
|
||||
BLUE=$(tput setaf 12)
|
||||
CYAN=$(tput setaf 14)
|
||||
|
||||
# Default values
|
||||
# Clearing vars and setting defaults
|
||||
fps=15
|
||||
mode=1
|
||||
dither=0
|
||||
colormax=256
|
||||
scale="-1"
|
||||
filetype="gif"
|
||||
webp_lossy=""
|
||||
webp_lossy_def=75
|
||||
loglevel="error"
|
||||
bayerscale=""
|
||||
colormax=""
|
||||
start_time=""
|
||||
end_time=""
|
||||
trim=""
|
||||
webp_lossy=""
|
||||
errorswitch=""
|
||||
errordiff=""
|
||||
picswitch=""
|
||||
@@ -75,7 +76,9 @@ while [[ $# -gt 0 ]]; do
|
||||
-s) start_time="$2"; shift 2;;
|
||||
-e) end_time="$2"; shift 2;;
|
||||
-c) colormax="$2"; shift 2;;
|
||||
-l) webp_lossy="$2"; shift 2;;
|
||||
# -l) webp_lossy="$2"; shift 2;;
|
||||
-l) if [[ ! "$2" =~ ^[0-9]+$ ]]; then webp_lossy=$webp_lossy_def; shift
|
||||
else webp_lossy="$2"; shift 2; fi ;;
|
||||
-v) loglevel="$2"; shift 2;;
|
||||
-k) errorswitch=1; shift;;
|
||||
-p) picswitch=1; shift;;
|
||||
@@ -138,7 +141,7 @@ if [[ "$fps" -le 0 ]]; then
|
||||
fi
|
||||
|
||||
# Validate Max Colors
|
||||
if [[ "$colormax" -lt 3 || "$colormax" -gt 256 ]]; then
|
||||
if [[ -n "$colormax" && "$colormax" -lt 3 || "$colormax" -gt 256 ]]; then
|
||||
echo ${RED}"Max colors (-c) must be between 3 and 256."${OFF}; exit 1
|
||||
fi
|
||||
|
||||
@@ -148,8 +151,8 @@ echo ${YELLOW}"$ffmpeg_version"${OFF}
|
||||
echo ${GREEN}Output file:${OFF} $output
|
||||
|
||||
## Putting together command to generate palette ##
|
||||
filters="fps=$fps,scale=$scale:-1:flags=lanczos"
|
||||
palette="$WD/palette_%05d.png"
|
||||
filters="fps=$fps,scale=$scale:-1:flags=lanczos"
|
||||
|
||||
# APNG muxer does not support multiple palettes so fallback to using palettegen diff mode
|
||||
if [[ "$filetype" == "apng" && "$mode" -eq 2 ]]; then
|
||||
@@ -250,7 +253,7 @@ if [[ ! -f "$output" ]]; then
|
||||
echo ${RED}"Failed to generate animation: $output not found"${OFF}; exit 1
|
||||
fi
|
||||
|
||||
# Open output if picswitch is enabled
|
||||
# Open output file if picswitch is enabled
|
||||
if [[ -n "$picswitch" ]]; then
|
||||
xdg-open "$output"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user