Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Created December 29, 2021 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hermann-SW/364ccd490527555bbbd4ea94cbbebcb2 to your computer and use it in GitHub Desktop.
Save Hermann-SW/364ccd490527555bbbd4ea94cbbebcb2 to your computer and use it in GitHub Desktop.
Bash script determines and shows the important frame from multiple exposure raspivid video
#!/bin/bash
function video_length {
ffprobe -v error -show_entries format=duration \
-of default=noprint_wrappers=1:nokey=1 $1
}
h264=`basename $1 .h264`
mp1=${h264}.mp4
mp2=${h264}2.mp4
rm -f $mp1 $mp2
ffmpeg -loglevel -8 -r 57 -i $1 -c copy $mp1
video_length $mp1
ffmpeg -loglevel -8 -sseof -2 -i $mp1 -c copy $mp2
video_length $mp2
rm -f ${h264}.frame.*
ffmpeg -loglevel -8 -i $mp2 ${h264}.frame.%04d.png
frame=`ls -l ${h264}.frame.0* | grep "pi pi [^ ]" | head -1 | cut -f10- -d\ `
echo $frame
eog $frame
@Hermann-SW
Copy link
Author

This script is for video recorded at framerate 57fps (Raspberry v1 camera mode 5, 1296x730).

$ ./show_multexp tst.h264
6.514000
2.304000
tst.frame.0050.png

374.8m/s (supersonic) pellet inflight captured with 10KHz PWM frequency and 2µs flash durations:
https://forums.raspberrypi.com/viewtopic.php?p=1955243#p1955243

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