Created
June 1, 2024 07:14
-
-
Save stvoidit/03328817a35fa24bba28ced71cf64c92 to your computer and use it in GitHub Desktop.
important! I am using my ffmpeg compilation from master, so this should work for ffmpeg versions => 6. The current fastest way to create a screencast for videos of any length. A 2.5-hour video in 1080p quality is processed in about 18 seconds. Please note, I use -hwaccel auto which speeds up decoding.
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
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "usage: ffmpeg_thumbnails.sh PATH_TO_VIDEOFILE" | |
exit | |
fi | |
MOVIE=$1 | |
MOVIE_NAME=$(basename "$MOVIE") | |
OUT_FILENAME="${MOVIE_NAME%.*}_preview.jpeg" | |
OUT_DIR=$(pwd) | |
OUT_FILEPATH="$OUT_DIR/$OUT_FILENAME" | |
mkdir -p $OUT_DIR | |
echo $OUT_FILEPATH | |
WIDTH=720 | |
COLS=8 | |
ROWS=8 | |
TOTAL_DURATION=$(ffprobe -v panic -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$MOVIE" 2>/dev/null) | |
TOTAL_IMAGES=$(bc <<<"scale=20;$COLS*$ROWS") | |
PERIOD_EVERY=$(bc <<<"scale=20;$TOTAL_DURATION/$TOTAL_IMAGES") | |
vf="fps=1/$PERIOD_EVERY,scale=${WIDTH}:-1,tile=${COLS}x${ROWS}:padding=10:margin=5:nb_frames=0" | |
ffmpeg -loglevel warning -hwaccel auto -skip_frame nokey -i "$MOVIE" -q:v 1 -frames:v 1 -vf "${vf}" -update 1 -an "$OUT_FILEPATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment