Created
January 13, 2020 15:24
-
-
Save gargolito/814b3b093bb4449a5133bebabc10de26 to your computer and use it in GitHub Desktop.
ffmpeg for video to gif
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
function vid2gif () { | |
vid="$1" | |
#start_time=00:00:01 | |
#duration=5 | |
height=-1 # input height halved , can replace with pixils . | |
width=480 # keeps aspect ratio . can replace with pixils . | |
fps=25 # frames per a second . | |
filters="fps=$fps,scale=$width:$height:flags=lanczos" | |
#ffmpeg -ss $start_time \ | |
# -t $duration \ | |
# -i "$vid" \ | |
ffmpeg -i "$vid" \ | |
-vf "$filters,palettegen" \ | |
-y palette.png && | |
ffmpeg -i "$vid" \ | |
-i palette.png \ | |
-lavfi "$filters [x]; [x][1:v] paletteuse" \ | |
-y "${vid/.*}".gif && rm palette.png | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment