Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. KOBEISSI Morgan revised this gist Jul 29, 2022. 1 changed file with 17 additions and 2 deletions.
    19 changes: 17 additions & 2 deletions Convert .mov or .MP4 to .gif.md
    Original file line number Diff line number Diff line change
    @@ -74,8 +74,23 @@ function v2g() {
    resolution="-s $resolution"
    fi

    echo "ffmpeg -i "$src" -pix_fmt rgb8 $fps $resolution "$target" && gifsicle -O3 "$target" -o "$target""
    ffmpeg -i "$src" -pix_fmt rgb8 $fps $resolution "$target" && gifsicle -O3 "$target" -o "$target"
    runcommand="ffmpeg -i "$src" -pix_fmt rgb8 $fps $resolution "$target" && gifsicle -O3 "$target" -o "$target""

    echo ""
    echo ".------------------------."
    echo "|\\\\//////// 90 min |"
    echo "| \\/ __ ______ __ |"
    echo "| / \|\.....|/ \ |"
    echo "| \__/|/_____|\__/ |"
    echo "| A |"
    echo "| ________________ |"
    echo "|___/_._o________o_._\___|"
    echo ""
    echo "ツ running >> $runcommand"
    echo "ツ ..."
    echo ""

    eval " $runcommand"
    osascript -e "display notification \"$target successfully converted and saved\" with title \"v2g complete\""
    }
    ```
  2. mcmoe revised this gist Jan 18, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Convert .mov or .MP4 to .gif.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.
    This note is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

    ## Need
    Convert .mov/.MP4 to .gif
    @@ -55,7 +55,7 @@ function v2g() {

    if [[ -z $src ]]; then
    echo -e "\nPlease call 'v2g --src <source video file>' to run this command\n"
    exit 1
    return 1
    fi

    if [[ -z $target ]]; then
  3. mcmoe revised this gist Jan 7, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Convert .mov or .MP4 to .gif.md
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ I tried to use some software to do the job, but my hands are tied since I don't

    ### Simplify usage via a bash function

    You can define the below function add it to your `.bashrc` or the like for use at anytime:
    You can define the below function and add it to your `.bashrc` or the like for use at anytime:

    ```sh
    function v2g() {
  4. mcmoe revised this gist Jan 7, 2022. 1 changed file with 53 additions and 0 deletions.
    53 changes: 53 additions & 0 deletions Convert .mov or .MP4 to .gif.md
    Original file line number Diff line number Diff line change
    @@ -33,3 +33,56 @@ I tried to use some software to do the job, but my hands are tied since I don't
    3. https://www.lcdf.org/gifsicle/
    4. full video tutorial with explanation https://www.youtube.com/watch?v=QKtRMFvvDL0


    ### Simplify usage via a bash function

    You can define the below function add it to your `.bashrc` or the like for use at anytime:

    ```sh
    function v2g() {
    src="" # required
    target="" # optional (defaults to source file name)
    resolution="" # optional (defaults to source video resolution)
    fps=10 # optional (defaults to 10 fps -- helps drop frames)

    while [ $# -gt 0 ]; do
    if [[ $1 == *"--"* ]]; then
    param="${1/--/}"
    declare $param="$2"
    fi
    shift
    done

    if [[ -z $src ]]; then
    echo -e "\nPlease call 'v2g --src <source video file>' to run this command\n"
    exit 1
    fi

    if [[ -z $target ]]; then
    target=$src
    fi

    basename=${target%.*}
    [[ ${#basename} = 0 ]] && basename=$target
    target="$basename.gif"

    if [[ -n $fps ]]; then
    fps="-r $fps"
    fi

    if [[ -n $resolution ]]; then
    resolution="-s $resolution"
    fi

    echo "ffmpeg -i "$src" -pix_fmt rgb8 $fps $resolution "$target" && gifsicle -O3 "$target" -o "$target""
    ffmpeg -i "$src" -pix_fmt rgb8 $fps $resolution "$target" && gifsicle -O3 "$target" -o "$target"
    osascript -e "display notification \"$target successfully converted and saved\" with title \"v2g complete\""
    }
    ```

    You can then call it as such

    ```sh
    v2g --src orig.mp4 --target newname --resolution 800x400 --fps 30
    ```

  5. @SheldonWangRJT SheldonWangRJT revised this gist Oct 1, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Convert .mov or .MP4 to .gif.md
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,7 @@ I tried to use some software to do the job, but my hands are tied since I don't

    ### Explanation
    1. Convert the file to gif using `ffmpeg`

    - input path argument `-i`
    - pixel format argument `-pix_fmt`
    - removing some frames using framerate argument `-r`
  6. @SheldonWangRJT SheldonWangRJT revised this gist Oct 1, 2019. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions Convert .mov or .MP4 to .gif.md
    Original file line number Diff line number Diff line change
    @@ -18,8 +18,12 @@ I tried to use some software to do the job, but my hands are tied since I don't
    4. `$ffmpeg -i in.mov -pix_fmt rgb8 -r 10 output.gif && gifsicle -O3 output.gif -o output.gif`

    ### Explanation
    1. Convert the file to gif using `ffmpeg` removing some frames using framerate argument `-r`
    2. Optimize the same output file with third option `-O3` and finally generate the file
    1. Convert the file to gif using `ffmpeg`
    - input path argument `-i`
    - pixel format argument `-pix_fmt`
    - removing some frames using framerate argument `-r`
    - end `ffmpeg` with new path/to/filename
    2. Optimize the same output file with third option `-O3` and rewrite the generated gif file from last step
    3. Notes: using `&&` to make sure the conversion sucess before optimizing

    ### References
  7. @SheldonWangRJT SheldonWangRJT revised this gist Oct 1, 2019. 2 changed files with 30 additions and 27 deletions.
    30 changes: 30 additions & 0 deletions Convert .mov or .MP4 to .gif.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

    ## Need
    Convert .mov/.MP4 to .gif

    ### Reason
    As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

    This is not limited to developer, anyone has this need can use this method to convert the files.

    ### Thoughts
    I tried to use some software to do the job, but my hands are tied since I don't have admin in my office comupter, but I do have brew installed. And I think using command line tool will be a good choice. So I will use *HomeBrew*, *ffmpeg*, *gifsicle* to do the job.

    ### Solution
    1. download HomeBrew
    2. `$brew install ffmpeg`
    3. `$brew install gifsicle`
    4. `$ffmpeg -i in.mov -pix_fmt rgb8 -r 10 output.gif && gifsicle -O3 output.gif -o output.gif`

    ### Explanation
    1. Convert the file to gif using `ffmpeg` removing some frames using framerate argument `-r`
    2. Optimize the same output file with third option `-O3` and finally generate the file
    3. Notes: using `&&` to make sure the conversion sucess before optimizing

    ### References
    1. https://brew.sh
    2. https://www.ffmpeg.org
    3. https://www.lcdf.org/gifsicle/
    4. full video tutorial with explanation https://www.youtube.com/watch?v=QKtRMFvvDL0

    27 changes: 0 additions & 27 deletions Convert .mov or .MP4 to .gif.txt
    Original file line number Diff line number Diff line change
    @@ -1,27 +0,0 @@
    *Need*:
    Convert .mov/.MP4 to .gif

    *Reason*:
    As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.
    This is not limited to developer, anyone has this need can use this method to convert the files.

    *Thoughts*:
    I tried to use some software to do the job, but my hands are tied since I don't have admin in my office comupter, but I do have brew installed. And I think using command line tool will be a good choice. So I will use *HomeBrew*, *ffmpeg*, *gifsicle* to do the job.

    *Solution*:
    1. download HomeBrew
    2. `$brew install ffmpeg`
    3. `$brew install gifsicle`
    4. `$ffmpeg -i in.mov -pix_fmt rgb8 -r 10 output.gif && gifsicle -O3 output.gif -o output.gif`

    *Explanation*:
    1. Convert the file to gif using *ffmpeg* removing some frames using -r
    2. Optimize the same output file with third option -O3 and finally generate the file
    3. Notes: using `&&` to make sure the conversion sucess before optimizing

    *References*:
    1. https://brew.sh
    2. https://www.ffmpeg.org
    3. https://www.lcdf.org/gifsicle/
    4. full video tutorial with explanation https://www.youtube.com/watch?v=QKtRMFvvDL0

  8. @SheldonWangRJT SheldonWangRJT renamed this gist Feb 13, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt → Convert .mov or .MP4 to .gif.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    *Need*:
    Convert .mov to .gif
    Convert .mov/.MP4 to .gif

    *Reason*:
    As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.
  9. @SheldonWangRJT SheldonWangRJT revised this gist Aug 14, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,6 @@
    3. `$brew install gifsicle`
    4. `$ffmpeg -i in.mov -pix_fmt rgb8 -r 10 output.gif && gifsicle -O3 output.gif -o output.gif`


    *Explanation*:
    1. Convert the file to gif using *ffmpeg* removing some frames using -r
    2. Optimize the same output file with third option -O3 and finally generate the file
  10. @SheldonWangRJT SheldonWangRJT revised this gist Aug 14, 2017. 1 changed file with 1 addition and 9 deletions.
    10 changes: 1 addition & 9 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,34 +1,26 @@
    *Need*:

    Convert .mov to .gif

    *Reason*:

    As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

    This is not limited to developer, anyone has this need can use this method to convert the files.

    *Thoughts*:

    I tried to use some software to do the job, but my hands are tied since I don't have admin in my office comupter, but I do have brew installed. And I think using command line tool will be a good choice. So I will use *HomeBrew*, *ffmpeg*, *gifsicle* to do the job.


    *Solution*:

    1. download HomeBrew
    2. `$brew install ffmpeg`
    3. `$brew install gifsicle`
    4. `$ffmpeg -i in.mov -pix_fmt rgb8 -r 10 output.gif && gifsicle -O3 output.gif -o output.gif`


    *Explanation*:

    *Explanation*:
    1. Convert the file to gif using *ffmpeg* removing some frames using -r
    2. Optimize the same output file with third option -O3 and finally generate the file
    3. Notes: using `&&` to make sure the conversion sucess before optimizing

    *References*:

    1. https://brew.sh
    2. https://www.ffmpeg.org
    3. https://www.lcdf.org/gifsicle/
  11. @SheldonWangRJT SheldonWangRJT created this gist Aug 14, 2017.
    36 changes: 36 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    *Need*:

    Convert .mov to .gif

    *Reason*:

    As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

    This is not limited to developer, anyone has this need can use this method to convert the files.

    *Thoughts*:

    I tried to use some software to do the job, but my hands are tied since I don't have admin in my office comupter, but I do have brew installed. And I think using command line tool will be a good choice. So I will use *HomeBrew*, *ffmpeg*, *gifsicle* to do the job.


    *Solution*:

    1. download HomeBrew
    2. `$brew install ffmpeg`
    3. `$brew install gifsicle`
    4. `$ffmpeg -i in.mov -pix_fmt rgb8 -r 10 output.gif && gifsicle -O3 output.gif -o output.gif`


    *Explanation*:

    1. Convert the file to gif using *ffmpeg* removing some frames using -r
    2. Optimize the same output file with third option -O3 and finally generate the file
    3. Notes: using `&&` to make sure the conversion sucess before optimizing

    *References*:

    1. https://brew.sh
    2. https://www.ffmpeg.org
    3. https://www.lcdf.org/gifsicle/
    4. full video tutorial with explanation https://www.youtube.com/watch?v=QKtRMFvvDL0