Skip to content

Instantly share code, notes, and snippets.

@salmedina
Created July 31, 2020 22:09
Show Gist options
  • Save salmedina/986ac98ed7f1470b7f1cb4f039dd78ec to your computer and use it in GitHub Desktop.
Save salmedina/986ac98ed7f1470b7f1cb4f039dd78ec to your computer and use it in GitHub Desktop.
FFMPEG extract keyframes from video
#!/bin/bash
START_TIME=$1
VIDEO_PATH=$2
DURATION=$3
OUTPUT_DIR=$4
ffmpeg -ss ${START_TIME} -i ${VIDEO_PATH} -t ${DURATION} -q:v 2 -vf select="eq(pict_type\,PICT_TYPE_I)" -vsync 0 ${OUTPUT_DIR}/%03d.jpg
@salmedina
Copy link
Author

This script extracts the I-frames from a given video in case it has them. If it doesn't, then it will extract all the frames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment