Last active
November 29, 2016 16:54
-
-
Save averissimo/3f40deac1ca22cc6658e2b2b56131ccc to your computer and use it in GitHub Desktop.
Creating GIFs easily with ffcast
This file contains 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
#!/bin/bash | |
# | |
# my_ffcast takes the same options as ffcast | |
# -s: part of screen | |
# -w: window | |
# ... | |
if [ -z $1 ] | |
then | |
option=-s | |
else | |
option=$@ | |
fi | |
TMP_AVI=$(mktemp /tmp/outXXXXXXXXXX.avi) | |
DEST_FOLDER=~/Pictures/gif-casts/ | |
echo "" | |
echo "" | |
echo "There is a 03 second delay after the window is set to " | |
echo " remove any window glitches, check the output to see " | |
echo " when the recording actually starts" | |
echo "------------------------------------------------------" | |
ffcast -vv $option lag 3 ~/work/apps/ffmpeg/ffmpeg -f x11grab -s %s -i %D+%c -r 15 -vcodec huffyuv -y $TMP_AVI | |
v2gif $TMP_AVI | |
mv ${TMP_AVI%.*}.gif $DEST_FOLDER | |
echo "" | |
echo "File generated at ${TMP_AVI%.*}.gif and moved to $DEST_FOLDER" |
This file contains 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
#!/bin/bash | |
# credit to @lolilolicon for improving this script!! | |
(($#)) || { printf 'usage: %s <video>\n' "${0##*/}" >&2; exit; } | |
[[ ${1,,} == *.gif ]] && exit | |
ffmpeg() { | |
command ffmpeg -hide_banner -loglevel error -nostdin "$@" | |
} | |
video_to_gif() { | |
ffmpeg -i "$1" -vf palettegen -f image2 -c:v png - | | |
ffmpeg -i "$1" -i - -filter_complex paletteuse "$2" | |
} | |
set -- "$1" "${1%.*}.gif" | |
printf 'converting: %s ...' "$1" >&2 | |
video_to_gif "$@" && | |
printf '\r\e[Kwritten to: %s\n' "$2" >&2 | |
# vim:et:sw=4:ts=4: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@lolilolicon you're very welcome!!
your bash skills are awesome!! going to update my scripts :)
ps. just saw you comment now and the wiki page seems simple and awesome, I'd love to improve but can't see on what :p