Skip to content

Instantly share code, notes, and snippets.

@hernan
Forked from rock3r/giffify.py
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save hernan/b1cdac79115ba42a163a to your computer and use it in GitHub Desktop.

Select an option

Save hernan/b1cdac79115ba42a163a to your computer and use it in GitHub Desktop.

Revisions

  1. @rock3r rock3r revised this gist Jul 4, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions giffify.sh
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@
    # License for any modification to the original (linked below):
    # ----------------------------------------------------------------------------
    # "THE BEER-WARE LICENSE" (Revision 42):
    # <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
    # Sebastiano Poggi wrote this file. As long as you retain this notice you
    # can do whatever you want with this stuff. If we meet some day, and you think
    # this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
    # this stuff is worth it, you can buy me a beer in return.
    # ----------------------------------------------------------------------------
    #
    # Based upon http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
  2. @rock3r rock3r revised this gist Jul 3, 2015. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion giffify.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,13 @@
    #!/bin/sh
    # Originally from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
    # License for any modification to the original (linked below):
    # ----------------------------------------------------------------------------
    # "THE BEER-WARE LICENSE" (Revision 42):
    # <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
    # can do whatever you want with this stuff. If we meet some day, and you think
    # this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
    # ----------------------------------------------------------------------------
    #
    # Based upon http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
    # Usage: giffify.sh inputFile outputFile [targetHeight] [targetFps]
    # Defaults: defaultHeight = 500px, targetFps = 15

  3. @rock3r rock3r created this gist Jul 3, 2015.
    24 changes: 24 additions & 0 deletions giffify.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/sh
    # Originally from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
    # Usage: giffify.sh inputFile outputFile [targetHeight] [targetFps]
    # Defaults: defaultHeight = 500px, targetFps = 15

    inputFile="$1"
    outputFile="$2"
    desiredHeight=$3
    if [[ -z $desiredHeight ]]; then
    desiredHeight=500
    fi
    fps=$4
    if [[ -z $fps ]]; then
    fps=15
    fi

    palette="palette.png"
    filters="fps=$fps,scale=-1:$desiredHeight:flags=lanczos"

    ffmpeg -v warning -i $inputFile -vf "$filters,palettegen" -y $palette
    if [[ -f $palette ]]; then
    ffmpeg -v warning -i $inputFile -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $outputFile
    rm $palette
    fi