Skip to content

Instantly share code, notes, and snippets.

@thiagogabriel
Forked from fnando/giffy
Created June 23, 2013 02:48

Revisions

  1. @fnando fnando revised this gist Jun 5, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion giffy
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/usr/bin/env bash
    if [[ ! -f "$1" ]]; then
    echo "Movie file not found"
    echo "=> Movie file not found"
    exit 1
    fi

  2. @fnando fnando created this gist Jun 4, 2013.
    35 changes: 35 additions & 0 deletions giffy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/env bash
    if [[ ! -f "$1" ]]; then
    echo "Movie file not found"
    exit 1
    fi

    tempfile=/tmp/output.gif

    rm -f $tempfile

    echo "=> Converting $1 to GIF"
    ffmpeg -i "$1" -pix_fmt rgb24 "$tempfile" > /tmp/giffy.log 2>&1

    if [[ ! -f "$tempfile" ]]; then
    echo "=> Error while converting $1 to GIF"
    echo "=> Check the file /tmp/giffy.log"
    exit 1
    fi

    filename=$(basename "$1")
    filename="${filename%.*}"
    dir=$(dirname "$1")
    output="$dir/$filename.gif"

    echo "=> Exporting optimized GIF to $output"
    convert -layers Optimize "$tempfile" "$output" > /tmp/giffy.log 2>&1

    if [[ ! -f "$output" ]]; then
    echo "=> Error while exporting $output"
    echo "=> Check the file /tmp/giffy.log"
    exit 1
    fi

    rm $tempfile
    echo "=> Done!"