Skip to content

Instantly share code, notes, and snippets.

@sr9yar
Created February 21, 2019 08:38
Show Gist options
  • Save sr9yar/05c371d813f834daf735b8365a267165 to your computer and use it in GitHub Desktop.
Save sr9yar/05c371d813f834daf735b8365a267165 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Saves the last frame of
# mp4/h264 matroska as png
# with ffmpeg
input_fn='output.mp4'
image_fn='output.png'
rm -f $image_fn
frame_count=`ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 $input_fn`
ffmpeg -i $input_fn -vf "select='eq(n,$frame_count-1)'" -vframes 1 "$image_fn" 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment