this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 64 lines 1.9 kB view raw
1#!/bin/sh 2usage() { 3 printf '%b\n' "${0##*/} -i <input_file> [OPTIONS]" \ 4 "\noptions:" \ 5 "\t-S TIMESTAMP - timestamp to start the gif" \ 6 "\t-d SECONDS - how long the gif should be" \ 7 "\t-f FPS - framerate of the gif" \ 8 "\t-o FILE - output file (default: out.gif)" \ 9 "\t-s SCALE - border size (default: 1)" 10} 11 12while [ "$*" ] 13do 14 case $1 in 15 - ) shift; continue ;; 16 -- ) shift; break ;; 17 -* ) flag=${1#-}; shift ;; 18 * ) shift; continue ;; 19 esac 20 21 while [ "$flag" ] 22 do 23 arg=${flag%"${flag#?}"} 24 25 case $arg in 26 S ) VID2GIF_START=$1; shift ;; 27 d ) VID2GIF_DURATION=$1; shift ;; 28 f ) VID2GIF_FPS=$1; shift ;; 29 h ) usage; exit 0 ;; 30 i ) VID2GIF_INPUT_FILE=$1; shift ;; 31 o ) VID2GIF_OUTPUT_FILE=$1; shift ;; 32 s ) VID2GIF_SCALE=$1; shift ;; 33 * ) printf '%s\n' "${0##*/}: -$arg: invalid argument" 1>&2 34 usage 1>&2; exit 1 ;; 35 esac 36 37 flag=${flag#?} 38 done 39done 40 41[ -z "$VID2GIF_INPUT_FILE" ] && { 42 printf '%s\n' "${0##*/}: missing input video" 1>&2 43 usage 1>&2; exit 1 44} 45 46fps= 47[ -n "$VID2GIF_FPS" ] && fps="fps=$VID2GIF_FPS," 48 49: "${VID2GIF_SCALE:=1}" 50: "${VID2GIF_OUTPUT_FILE:=out.gif}" 51 52filters="${fps}scale=iw*${VID2GIF_SCALE}:-1:flags=lanczos" 53palette_file=$(mktemp --tmpdir XXX.png) 54 55ffmpeg -hide_banner -loglevel warning \ 56 ${VID2GIF_START:+"-ss" "$VID2GIF_START"} ${VID2GIF_DURATION:+"-t" "$VID2GIF_DURATION"} \ 57 -i "$VID2GIF_INPUT_FILE" -vf "$filters,palettegen" -update true \ 58 -y "$palette_file" && \ 59ffmpeg -hide_banner -loglevel warning \ 60 ${VID2GIF_START:+"-ss" "$VID2GIF_START"} ${VID2GIF_DURATION:+"-t" "$VID2GIF_DURATION"} \ 61 -i "$VID2GIF_INPUT_FILE" -i "$palette_file" -filter_complex "$filters,paletteuse" \ 62 "$VID2GIF_OUTPUT_FILE" 63 64rm "$palette_file"