Skip to content

Instantly share code, notes, and snippets.

@nicnocquee
Created February 24, 2016 11:16
Show Gist options
  • Select an option

  • Save nicnocquee/51a52f1fb99c983d3c38 to your computer and use it in GitHub Desktop.

Select an option

Save nicnocquee/51a52f1fb99c983d3c38 to your computer and use it in GitHub Desktop.
Get twitter video from url then convert to gif. Usage: ./get_twitter_video_to_gif <url> <filename>
#/bin/sh
curl -s -L -G "$1" > tmp
url=`grep -o 'https:\/\/pbs\.twimg\.com\/tweet_video\/.*\.mp4' tmp`
echo $url
curl -s -G $url > $2.mp4
palette="palette.png"
filters="fps=10,scale=320:-1:flags=lanczos"
ffmpeg -v warning -i $2.mp4 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $2.mp4 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2.gif
rm -f tmp
rm -f $palette
rm -f $2.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment