Skip to content

Instantly share code, notes, and snippets.

@imkevinxu
Last active June 17, 2016 17:35
Show Gist options
  • Save imkevinxu/96e3cb1d7e308f867a0f to your computer and use it in GitHub Desktop.
Save imkevinxu/96e3cb1d7e308f867a0f to your computer and use it in GitHub Desktop.

Revisions

  1. imkevinxu renamed this gist Mar 29, 2015. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions movtogif.sh → vidtogif.sh
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,15 @@
    # Convert a .mov Quicktime video to gif
    # @param $1 - .mov file name like `animation.mov`
    # Convert an animated video to gif
    # Works best for videos with low color palettes like Dribbble shots
    #
    # @param $1 - video file name like `animation.mov`
    # @param @optional $2 - resize parameter as widthxheight like `400x300`
    #
    # Example: movtogif animation.mov 400x300
    # Example: vidtogif animation.mov 400x300
    # Requirements: ffmpeg and gifsicle. Can be downloaded via homebrew
    #
    # http://chrismessina.me/b/13913393/mov-to-gif

    function movtogif() {
    function vidtogif() {
    if [ -n "$1" ]
    then
    mkdir pngs gifs
    @@ -23,6 +25,6 @@ function movtogif() {
    cd ..
    rm -rf pngs gifs
    else
    echo "Use .mov file as first parameter"
    echo "Use video file as first parameter"
    fi
    }
  2. imkevinxu revised this gist Feb 18, 2015. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions movtogif.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,12 @@
    # Convert a .mov Quicktime video to gif
    # @param $1 - .mov file name like `animation.mov`
    # @param @optional $2 - resize parameter as widthxheight like `400x300`
    #
    # Example: movtogif animation.mov 400x300
    # Requirements: ffmpeg and gifsicle. Can be downloaded via homebrew
    #
    # http://chrismessina.me/b/13913393/mov-to-gif

    function movtogif() {
    if [ -n "$1" ]
    then
  3. imkevinxu created this gist Feb 18, 2015.
    19 changes: 19 additions & 0 deletions movtogif.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    function movtogif() {
    if [ -n "$1" ]
    then
    mkdir pngs gifs
    ffmpeg -i "$1" -r 10 pngs/frame_%04d.png
    sips -s format gif pngs/*.png --out gifs/
    cd gifs
    if [ -z "$2" ]
    then
    gifsicle *.gif --optimize=3 --delay=3 --loopcount > ../animation.gif
    else
    gifsicle *.gif --optimize=3 --delay=3 --loopcount --resize "$2" > ../animation.gif
    fi
    cd ..
    rm -rf pngs gifs
    else
    echo "Use .mov file as first parameter"
    fi
    }