Skip to content

Instantly share code, notes, and snippets.

@romanr
Forked from NelsonMinar/lastframe.sh
Created October 21, 2024 15:50
Show Gist options
  • Save romanr/2550ddeac080bf3f9478502c296b3e61 to your computer and use it in GitHub Desktop.
Save romanr/2550ddeac080bf3f9478502c296b3e61 to your computer and use it in GitHub Desktop.
Extract last frame of a video file
#!/bin/bash
fn="$1"
of=${fn%.*}.jpg
lf=`ffprobe -show_streams "$fn" 2> /dev/null | awk -F= '/^nb_frames/ { print $2-1 }'`
rm -f "$of"
ffmpeg -i "$fn" -vf "select='eq(n,$lf)'" -vframes 1 "$of" 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment