Advertisement
Guest User

Untitled

a guest
May 29th, 2015
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #!/usr/bin/env zsh
  2. setopt ERR_EXIT
  3. if [[ -z $1 ]]
  4. then
  5. cat <<EOF
  6. Usage: $0 /path/to/test-image.png
  7.  
  8. Warning: run script from empty directory, otherwise it may delete your files (e.g. q*.png).
  9. EOF
  10. false
  11. fi
  12. ffmpeg=(ffmpeg -hide_banner -loglevel error)
  13. $ffmpeg -i $1 -vf scale=400:-1 -vframes 1 -y ref.png
  14. aspect=$(( $(identify -format '%w.0/%h' ref.png) ))
  15. for codec in vp8 vp9
  16. do
  17. for q in {00..63..8} 60 61 62 63
  18. do
  19. $ffmpeg -stats -i ref.png -c:v $codec -qmin $q -qmax $q -b:v 0 -y sample.webm
  20. $ffmpeg -f webm -i sample.webm -y sample.png
  21. psnr="$(compare -metric PSNR -fuzz 2\% ref.png sample.png compare.png 2>&1 || :)"
  22. convert sample.png compare.png "$( ((aspect > 1)) && printf "-" || printf "+")append" \
  23. -background wheat1 "label:$(
  24. printf 'QP: %d PSNR: %s dB SIZE: %.2f KiB' $q $psnr $(($(stat -c %s sample.webm)/1024.0))
  25. )" -gravity Center -append q$q.png
  26. done
  27. convert -background wheat1 label:$codec -gravity Center <(montage -geometry +0+0 q*.png -) -append $codec.png
  28. rm q*.png sample.{webm,png} compare.png
  29. done
  30. rm ref.png
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement