Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # we need youtube-dl, ffmpeg, imagemagick and gnupot installed
- #dnf install youtube-dl ffmpeg imagemagick gnuplot
- # 1.05M
- video="https://www.youtube.com/watch?v=Y0ZKEGZpggI"
- code="133"
- width="21"
- height="4"
- x="82"
- y="15"
- # 1.04M
- #video="https://www.youtube.com/watch?v=KYtJzRcvOzk"
- #code="133"
- #width="19"
- #height="5"
- #x="90"
- #y="23"
- # go get the video, and nevermind the audio
- youtube-dl $video -f $code -o vid.mp4
- mkdir frames
- # we crop the 1up and dump each frame.
- # we take special care to not get too much glow from the score underneath it.
- # when 1up is present the brightness value will be greater than a black screen.
- ffmpeg -i vid.mp4 -filter:v "crop=$width:$height:$x:$y" -f image2 frames/frame-%06d.png
- # for each cropped frame go get average brightness and dump it to 'results'
- # we number each line, where 0 is the first frame of the video
- files=`find ./frames -name "*.png" -print | sort`
- n=0
- for f in $files; do
- echo -n "$n, " >> results
- convert $f -colorspace gray -format "%[fx:100*mean]%%" info: >> results
- echo >> results
- n=`expr $n + 1`
- done
- cat << EOF > plot
- set terminal svg size 600000 600 fname 'Sans' fsize 7
- set output 'results.svg'
- set xtics 1000
- plot 'results' with lines
- EOF
- gnuplot plot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement