Last active
March 23, 2022 11:23
-
-
Save JaHIY/ba48a646e56016178465f68172f721d7 to your computer and use it in GitHub Desktop.
convert telegram video sticker (webm) to animated gif
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
find . -name '*.webm' -type f -print0 | xargs -0 -I'{}' -n 1 -- bash -c 'ffmpeg -y -loglevel warning -c:v libvpx-vp9 -i "$0" "${0%.*}.webp"' '{}' | |
gimp -d -f -n -i -b '(define (webp->gif filename) (let* ((image (car (file-webp-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image))) (new-filename (string-append (substring filename 0 (- (string-length filename) 5)) ".gif"))) (gimp-image-convert-indexed image CONVERT-DITHER-NONE CONVERT-PALETTE-GENERATE 255 FALSE TRUE "") (file-gif-save RUN-NONINTERACTIVE image drawable new-filename new-filename FALSE TRUE 0 2) (gimp-image-delete image))) (define (batch-webp->gif pattern) (let* ((filelist (cadr (file-glob pattern 1)))) (for-each webp->gif filelist))) (batch-webp->gif "*.webp")' -b '(gimp-quit 0)' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment