Skip to content

Instantly share code, notes, and snippets.

@koji
Last active September 3, 2018 22:13
Show Gist options
  • Save koji/a843e43ad04f3c8635387e120bd6e23e to your computer and use it in GitHub Desktop.
Save koji/a843e43ad04f3c8635387e120bd6e23e to your computer and use it in GitHub Desktop.
ffmpeg

ffmpeg mini-workshop@ITP

setup environment

install homebrew

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If you haven't installed Xcode yet, you will need to hit the following command.
$ xcode-select --install

If you can't install 
$ sudo xcode-select --install

install ffmpeg

$ brew install ffmpeg

For Windows users

If you are a windows user, please check this site(https://www.ffmpeg.org/download.html).

ffmpeg commands

Convert mov --> mp4 / gif

$ ffmpeg -i test.mov test.mp4
$ ffmpeg -i test.mp4 test.gif

Generate image from video file

$ ffmpeg -i input.mp4 -vcodec png image_%04d.png
$ ffmpeg -i input.mp4 -vcodec jpg image_%04d.jpg

Resize video file

ffmpeg -i input.mp4 -vf scale=960:540 output.mp4

Generate video file from images

$ ffmpeg -r 30 -i image_%04d.png -vcodec libx264 -pix_fmt yuv420p -r 30 out.mp4
$ ffmpeg -r 30 -i image_%04d.jpg -vcodec libx264 -pix_fmt yuv420p -r 30 out.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment