Last active
October 4, 2022 14:44
-
-
Save dill/88cc9b997b82c6a1f624 to your computer and use it in GitHub Desktop.
imagemagick and ffmpeg cheatsheet
This file contains 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
# convert mp4 to gif | |
# converts in.mp4 to out.gif, using 0-20s of the mp4 at resolution 640x480 | |
ffmpeg -ss 00:00:00.000 -i in.mp4 -pix_fmt rgb24 -r 10 -s 640x480 -t 00:00:20.000 out.gif | |
# alternative mp4 to gif (using imagemagick for the second step) | |
ffmpeg -i input.mp4 -r 10 output%05d.png | |
convert output*.png output.gif | |
# strip audio out of a video file (to aac) | |
ffmpeg -i input_video.mp4 -vn -acodec copy output_audio.aac | |
# strip audio out of a video file (to mp3) | |
ffmpeg -i input_video.mp4 -vn output_audio.mp3 |
This file contains 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
# make a PDF smaller | |
# https://www.reddit.com/r/RemarkableTablet/comments/8bh8gz/reducing_file_size_of_pdfs/ | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=OUTPUTFILENAME.pdf INPUTFILENAME.pdf |
This file contains 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
# some recipes for imagemagick | |
# the * wildcard goes sequentially over files in order | |
# "stack" images one ontop of the other to make one long (height-wise) image | |
convert -append *.png out.png | |
# "stack" images side-by-side to make one long (width-wise) image | |
convert +append *.png out.png | |
# take a bunch of pngs and make a gif | |
convert -delay 5 -loop 0 *.png animated.gif | |
# trim the whitespace around a bunch of images (useful for plots) | |
mogrify -trim *.png | |
# trim around one image | |
convert image.png -fuzz 1% -trim +repage result.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment