Skip to content

Instantly share code, notes, and snippets.

@oglops
Created August 25, 2014 04:36
Show Gist options
  • Save oglops/2ed0dc5d183c439a650e to your computer and use it in GitHub Desktop.
Save oglops/2ed0dc5d183c439a650e to your computer and use it in GitHub Desktop.
add ability to grab window by passing -w
#!/usr/bin/env bash
# the convert call depends on whether you have h264 support in
# convert -list format
# if you don't have it , then record to -vcodec huffyuv
# if you see convert: Not enough pixel data `/tmp/x.avi' @ avi.c/ReadAVIImage/1243.
# maybe try removing -vcodec completely and use uncompressed avi
if [ $# -ne 1 ]; then
echo -e "Usage: \n\t git-batch.sh -wru\n\n"
exit 0
fi
while getopts "ruw" OPTION; do
case $OPTION in
w) echo recording window
RECORD_WINDOW=true
FFCAST_PARAM="-w"
;& # this means continue to execute the next block without testing its pattern
r) echo recording
TMP_AVI=$(mktemp /tmp/outXXXXXXXXXX.avi)
TMP_GIF=$(mktemp /tmp/outXXXXXXXXXX.gif)
if [ "$RECORD_WINDOW" = true ] ; then
echo "recording window is true"
fi
# XXX=
# echo XXX , $XXX
RECORD_CMD=$(echo ffcast ${FFCAST_PARAM:--s} ffmpeg -y -r 20 $TMP_AVI \&\& convert -set delay 10 -layers Optimize $TMP_AVI $TMP_GIF)
# echo record command : $RECORD_CMD
eval $RECORD_CMD
export TMP_GIF=$TMP_GIF
# gwenview $TMP_GIF >/dev/null 2>&1
gthumb --viewer $TMP_GIF >/dev/null 2>&1
echo recorded gif : $TMP_GIF
exit 0
;;
u) maxsize=2048
TMP_GIF=$(ls -t /tmp/out*.gif | head -1)
actualsize=$(du -k $TMP_GIF | cut -f 1)
echo actialsize: $actualsize
if [ $actualsize -ge $maxsize ]
then
TMP_GIF2=$(mktemp /tmp/outXXXXXXXXXX.gif)
gifsicle -O2 --colors 64 $TMP_GIF > $TMP_GIF2
TMP_GIF = $TMP_GIF2
fi
echo 'uploading gif : '$TMP_GIF
# http://imgur.com/tools
~/scripts/imgurbash.sh $TMP_GIF
exit 0
;;
*) # echo "Incorrect options provided" exit 1 ;;
echo "done"
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment