Skip to content

Instantly share code, notes, and snippets.

@dmitrydyomin
Created September 20, 2024 05:23
Show Gist options
  • Save dmitrydyomin/aaae2cde13bf0ab0c15ad50e3265a2f6 to your computer and use it in GitHub Desktop.
Save dmitrydyomin/aaae2cde13bf0ab0c15ad50e3265a2f6 to your computer and use it in GitHub Desktop.
Recipe of the week
#!/bin/bash
dir=s1
out=out
mkdir -p $out/$dir
re='^[0-9]+$'
for filename in $dir/*; do
frame=`ffmpeg -sseof -300 -i "$filename" -r 1 -loop 1 -i rotw.png -an -filter_complex 'blend=difference:shortest=1,blackframe=99:32' -f null - 2>&1 | grep blackframe | sed 's/.*frame\:\(.*\)/\1/' | tail -n1`
if [ -n "$frame" ] && [ "$frame" -eq "$frame" ] 2>/dev/null; then
echo "✅ Found ROTW frame: $frame in $filename"
ffmpeg -y -hide_banner -loglevel error -sseof -300 -i "$filename" -ss $(($frame / 25)) -c copy "$out/$filename"
else
echo "🚨 ROTW frame not found in $filename"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment