Skip to content

Instantly share code, notes, and snippets.

@davidejones
Last active February 10, 2020 17:23
Show Gist options
  • Save davidejones/095d2f2265a6d381b8a39c0b0d6cf64d to your computer and use it in GitHub Desktop.
Save davidejones/095d2f2265a6d381b8a39c0b0d6cf64d to your computer and use it in GitHub Desktop.
extract image from video and gif
#!/usr/bin/env bash
# image magick extract image from gif
convert Collaboration.gif[4] collaboration-static.gif
# ffmpeg extract image from timestamp
ffmpeg -ss 00:00:04 -i Collaboration.mp4 -vframes 1 collaboration.png
ffmpeg -ss 00:00:12 -i Alerts.mp4 -vframes 1 alerts.png
ffmpeg -ss 00:00:09 -i API.mp4 -vframes 1 api.png
ffmpeg -ss 00:00:07 -i APM.mp4 -vframes 1 apm.png
# converting animated gifs to mp4s
ffmpeg -i MASSIVE_GIF.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4
# video conversions
# make smaller
ffmpeg -i video.mp4 -vf scale=320:-1 video_small.mp4
# just compress?
ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
# youtube
ffmpeg -i input -c:v libx264 -preset slow -profile:v high -crf 18 -coder 1 -pix_fmt yuv420p -movflags +faststart -g 30 -bf 2 -c:a aac -b:a 384k -profile:a aac_low output
# just cut the video only
ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 cut.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment