Advertisement
TheAlkaris

makegif.sh with FFMPEG - Video to GIF conversion

Jan 29th, 2018
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.67 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # You'll have to modify the script if you want to change start_time and duration.
  4. # just remember, the longer the duration the bigger the GIF output. Most sites will only allow 3MB GIFs.
  5.  
  6. # Here'sa quick little ffmpeg video to GIF converter
  7. # its all so simple, and all you need to do is change
  8. # the format settings if desired for different outputs.
  9.  
  10. # actually before I can let you get started I just want
  11. # point out what the current options I have chosen are
  12. # just for this little script of mine.
  13.  
  14. ## -t duration (input/output)
  15. ## -ss position (input/output) seeks out time where to start at [ minutes - 00:00 | hours - 00:00:00 ]
  16. ## -y (global) overwrite output files without asking
  17. ## -vf filtergraph (output) create filtergraph specified by filtergrtaph and filter the stream
  18. ## -v loglevel
  19. ## -gifflags
  20. ## +transdiff (transparency support) / -transdiff (non-transparency support)
  21.  
  22. #
  23. # ok so now that is out the way here is the rest of the script
  24. #
  25.  
  26.  
  27. start_time=00:00                  # start time of GIF
  28. duration=5                    # duration of GIF
  29. palette="/tmp/palette.png"            # temporary palette
  30. filters="fps=20,scale=440:-1:flags=lanczos"   # FPS and Scale of GIF
  31.  
  32. ffmpeg -y -v warning -ss $start_time -t $duration -i $1 -vf "$filters,palettegen"  $palette
  33. ffmpeg -y -v warning -ss $start_time -t $duration  -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse=dither=bayer:bayer_scale=1" $2
  34.  
  35.  
  36. # you should be able to use the script like so;
  37. #
  38. ## $ ./makegif.sh video.mp4 anime.gif
  39. #
  40. # All credits to helping to make this script go to http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
  41. # additional info for ffmpeg usage at https://www.ffmpeg.org/ffmpeg.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement