Forked from SheldonWangRJT/Convert .mov or .MP4 to .gif.md
Last active
October 29, 2021 17:31
-
-
Save thedevsaddam/e9fa66029360fef463a8a2a7903dd785 to your computer and use it in GitHub Desktop.
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal
This file contains hidden or 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
| *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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment