Last active
March 7, 2017 05:20
-
-
Save ansballard/d8063217236aa934d669f0ad647738c5 to your computer and use it in GitHub Desktop.
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/sh | |
# https://trac.ffmpeg.org/wiki/Capture/Desktop | |
FILENAME=${1:-"screencast"} | |
FPS=${2:-"30"} | |
WIDTH=${3:-"1366"} | |
HEIGHT="768" | |
DIMENSIONS="${WIDTH}x${HEIGHT}" | |
MP4="$FILENAME.mp4" | |
PALETTE="/tmp/palette.png" | |
FILTERS="fps=$FPS,scale=$WIDTH:-1:flags=lanczos" | |
printf "\n\033[0;35mRecording to $MP4, $FPS fps, $DIMENSIONS...\033[0m\n\n" | |
ffmpeg -v error -framerate $FPS -video_size $DIMENSIONS -f x11grab -i :0.0+0,0 -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le $MP4 | |
printf "\n\033[0;35m$MP4 saved, converting to gif [$FPS fps, $DIMENSIONS > $FILENAME.gif]...\033[0m\n\n" | |
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html | |
ffmpeg -v warning -i $MP4 -vf "$FILTERS,palettegen" -y $PALETTE | |
ffmpeg -v warning -i $MP4 -i $PALETTE -lavfi "$FILTERS [x]; [x][1:v] paletteuse" -y $FILENAME.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment