Advertisement
Guest User

Untitled

a guest
Apr 4th, 2018
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.26 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # we need youtube-dl, ffmpeg, imagemagick and gnupot installed
  4. #dnf install youtube-dl ffmpeg imagemagick gnuplot
  5.  
  6. # 1.05M
  7. video="https://www.youtube.com/watch?v=Y0ZKEGZpggI"
  8. code="133"
  9. width="21"
  10. height="4"
  11. x="82"
  12. y="15"
  13.  
  14. # 1.04M
  15. #video="https://www.youtube.com/watch?v=KYtJzRcvOzk"
  16. #code="133"
  17. #width="19"
  18. #height="5"
  19. #x="90"
  20. #y="23"
  21.  
  22. # go get the video, and nevermind the audio
  23. youtube-dl $video  -f $code -o vid.mp4
  24. mkdir frames
  25.  
  26. # we crop the 1up and dump each frame.
  27. # we take special care to not get too much glow from the score underneath it.
  28.  
  29. # when 1up is present the brightness value will be greater than a black screen.
  30.  
  31. ffmpeg -i vid.mp4 -filter:v "crop=$width:$height:$x:$y" -f image2 frames/frame-%06d.png
  32.  
  33. # for each cropped frame go get average brightness and dump it to 'results'
  34. # we number each line, where 0 is the first frame of the video
  35. files=`find ./frames -name "*.png" -print | sort`
  36. n=0
  37. for f in $files; do
  38.   echo -n "$n, " >> results
  39.   convert $f -colorspace gray -format "%[fx:100*mean]%%" info: >> results
  40.   echo >> results
  41.   n=`expr $n + 1`
  42. done
  43.  
  44. cat << EOF > plot
  45. set terminal svg size 600000 600 fname 'Sans' fsize 7
  46. set output 'results.svg'
  47. set xtics 1000
  48. plot 'results' with lines
  49. EOF
  50. gnuplot plot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement