Skip to main content
added 24 characters in body
Source Link
Aphex
  • 211
  • 1
  • 4
  • 8

ffmpeg commands:

  1. Run this command so that ffmpeg can figure out a good palette:

     ffmpeg -y -i foo.mp4 -vf fps=30,scale=320:-1:flags=lanczos,palettegen palette.png
    
  2. Run this command to convert the mp4 file into gif:

     ffmpeg -y -i foo.mp4 -i palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" foo.gif
    

You might want to tweak the fps and scale. Smaller for either will result in better file size.

Making a simple alias function

You can also create an alias function like this. I added it to my .bashrc or .bash_profile:

function makegif {
  ffmpeg -y -i $1 -vf fps=30,scale=320:-1:flags=lanczos,palettegen palette.png
  ffmpeg -y -i $1 -i palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" $1.gif
}

And then just makegif foo

Note: You'll need ffmpeg of course. Get it here: https://www.ffmpeg.org/download.html or brew install ffmpeg

ffmpeg commands:

  1. Run this command so that ffmpeg can figure out a good palette:

     ffmpeg -y -i foo.mp4 -vf fps=30,scale=320:-1:flags=lanczos,palettegen palette.png
    
  2. Run this command to convert the mp4 file into gif:

     ffmpeg -y -i foo.mp4 -i palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" foo.gif
    

You might want to tweak the fps and scale. Smaller for either will result in better file size.

Making a simple alias function

You can also create an alias function like this. I added it to my .bashrc or .bash_profile:

function makegif {
  ffmpeg -y -i $1 -vf fps=30,scale=320:-1:flags=lanczos,palettegen palette.png
  ffmpeg -y -i $1 -i palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" $1.gif
}

And then just makegif foo

Note: You'll need ffmpeg of course. Get it here: https://www.ffmpeg.org/download.html

ffmpeg commands:

  1. Run this command so that ffmpeg can figure out a good palette:

     ffmpeg -y -i foo.mp4 -vf fps=30,scale=320:-1:flags=lanczos,palettegen palette.png
    
  2. Run this command to convert the mp4 file into gif:

     ffmpeg -y -i foo.mp4 -i palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" foo.gif
    

You might want to tweak the fps and scale. Smaller for either will result in better file size.

Making a simple alias function

You can also create an alias function like this. I added it to my .bashrc or .bash_profile:

function makegif {
  ffmpeg -y -i $1 -vf fps=30,scale=320:-1:flags=lanczos,palettegen palette.png
  ffmpeg -y -i $1 -i palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" $1.gif
}

And then just makegif foo

Note: You'll need ffmpeg of course. Get it here https://www.ffmpeg.org/download.html or brew install ffmpeg

Source Link
Aphex
  • 211
  • 1
  • 4
  • 8

ffmpeg commands:

  1. Run this command so that ffmpeg can figure out a good palette:

     ffmpeg -y -i foo.mp4 -vf fps=30,scale=320:-1:flags=lanczos,palettegen palette.png
    
  2. Run this command to convert the mp4 file into gif:

     ffmpeg -y -i foo.mp4 -i palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" foo.gif
    

You might want to tweak the fps and scale. Smaller for either will result in better file size.

Making a simple alias function

You can also create an alias function like this. I added it to my .bashrc or .bash_profile:

function makegif {
  ffmpeg -y -i $1 -vf fps=30,scale=320:-1:flags=lanczos,palettegen palette.png
  ffmpeg -y -i $1 -i palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" $1.gif
}

And then just makegif foo

Note: You'll need ffmpeg of course. Get it here: https://www.ffmpeg.org/download.html