Skip to content

Instantly share code, notes, and snippets.

@pgoeser
Created January 30, 2012 18:31
Show Gist options
  • Save pgoeser/1705838 to your computer and use it in GitHub Desktop.
Save pgoeser/1705838 to your computer and use it in GitHub Desktop.
double-blind resolution test to detect upscales from 720p to 1080p
#!/bin/bash
# double-blind resolution test to detect upscales from 720p to 1080p
# usage: upscale-detect.sh filename
#
# what's it doing: taking two screenshots at a random spot in a file, once with the video downscaled to 720p and upscaled back to 1080p, once without scaling filters. The order of the screensots is randomized.
#
# results: everything is in /tmp/upscale-detect
# shots are shot_a.png and shot_b.png (uncompressed)
# the file doubleblind_secret reveals which was the original.
#
# caveats:
# - fails if loading the video takes >2s
# - fails if the random position (0..2048s) is outside the video range
# - currently does not work with absolute paths
# - code is ugly
pos=$(( $RANDOM / 16 ))
order=$(( $RANDOM & 1 ))
path=`pwd`
mkdir /tmp/upscale-detect
cd /tmp/upscale-detect
rm shot*.png
if [[ $order -eq 0 ]]; then
(echo pause; sleep 2.0; echo screenshot; sleep 0.5; echo frame_step; sleep 0.5; echo quit) | mplayer "$path/$@" -vf scale=-2:720,scale=-2:1080,screenshot -sws 2 -ss $pos -slave -really-quiet
(echo pause; sleep 2.0; echo screenshot; sleep 0.5; echo frame_step; sleep 0.5; echo quit) | mplayer "$path/$@" -vf screenshot -sws 2 -ss $pos -slave -really-quiet
echo "original is b" >doubleblind_secret
else
(echo pause; sleep 2.0; echo screenshot; sleep 0.5; echo frame_step; sleep 0.5; echo quit) | mplayer "$path/$@" -vf screenshot -sws 2 -ss $pos -slave -really-quiet
(echo pause; sleep 2.0; echo screenshot; sleep 0.5; echo frame_step; sleep 0.5; echo quit) | mplayer "$path/$@" -vf scale=-2:720,scale=-2:1080,screenshot -sws 2 -ss $pos -slave -really-quiet
echo "original is a" >doubleblind_secret
fi
mv shot0001.png shot_a.png
mv shot0002.png shot_b.png
echo pos is $pos >> doubleblind_secret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment