-
-
Save shumink/420c79c73d165f12a45b6c1590b394e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Incorporate this function into your .bash_profile (.bashrc, .zshrc, or whatever you use...) | |
# Run `mov2frames name-of-mov.mov` to extract frames from the movie file | |
# Run `mov2frames name-of-mov.mov 300` to extract frames from the movie file at a maximum width of 300 pixels | |
# Frames will be exported into a `frames/` folder | |
# NOTE: if the frames folder exists and contains files that match the filename `frame_%03d.png`, no frames will be generated | |
mov2frames() { | |
if [ ! -z "$2" ] | |
then | |
size=$2 | |
else | |
size=-1 | |
fi | |
tmp_dir="./frames" | |
mkdir $tmp_dir | |
echo "\033[33m Extract frames $1 ($2px wide)" | |
echo "\033[32m ## Extracting frames..." | |
# Assumes video with 30 fps | |
ffmpeg -i $1 -vf scale=$size:-1 -r 30 $tmp_dir/frame_%03d.png | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment