Mercurial > mplayer.hg
annotate TOOLS/psnr-video.sh @ 16604:28716eae82c2
Don't pass NULL pointers to demux_info_add()
author | rtognimp |
---|---|
date | Mon, 26 Sep 2005 20:13:10 +0000 |
parents | d9697b778be2 |
children | fca80748d11b |
rev | line source |
---|---|
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
1 #!/bin/sh |
16473 | 2 # Helper script to ease comparing the PSNR between two video files |
3 # Copyleft 2005 by Matthias Wieser | |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
4 # This file comes under GPL, see http://www.gnu.org/copyleft/gpl.html for more |
16473 | 5 # information on its licensing. |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
6 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
7 TEMPDIR="/tmp/psnr_video" |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
8 WORKDIR=`pwd`/ |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
9 if [ $# -le 1 ]; then |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
10 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
11 echo "Usage: `basename $0` <file1> <file2> [<frames>] [<options1>] [<options2>]" |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
12 echo |
16473 | 13 echo " <file1> and <file2> are the files for which the PSNR should be calculated." |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
14 echo " [<frames>] is the number of frames to process, starting from frame 1." |
16473 | 15 echo " [<options1>] are additional MPlayer options for <file1>." |
16 echo " [<options2>] are additional MPlayer options for <file2>." | |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
17 echo |
16473 | 18 echo " Be aware that `basename $0` needs a lot of temporary space inside /tmp/." |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
19 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
20 echo "Example:" |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
21 echo " ./`basename $0` ./orig.avi ./test.avi 250 \"\" \"-vf pp=ac\"" |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
22 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
23 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
24 exit 1 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
25 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
26 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
27 FILE1=$1 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
28 FILE2=$2 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
29 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
30 LastFrame=-1 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
31 if [ $# -ge 3 ]; then |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
32 LastFrame=$3 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
33 echo |
16473 | 34 echo "Will process $LastFrame frames." |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
35 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
36 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
37 if [ $# -ge 4 ]; then |
16473 | 38 FILE1_Options=$4 |
39 echo "MPlayer options for ${FILE1}: $FILE1_Options" | |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
40 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
41 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
42 if [ $# -ge 5 ]; then |
16473 | 43 FILE2_Options=$5 |
44 echo "Mplayer options for ${FILE2}: $FILE2_Options" | |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
45 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
46 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
47 mkdir -p ${TEMPDIR}/FILE1 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
48 mkdir -p ${TEMPDIR}/FILE2 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
49 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
50 ### File 1 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
51 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
52 echo "############## $FILE1 #################" |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
53 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
54 cd ${TEMPDIR}/FILE1 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
55 |
16473 | 56 rm -f *ppm |
57 rm -f *del | |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
58 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
59 if [ $LastFrame -ge 0 ]; then |
16473 | 60 mplayer $FILE1_Options -frames $LastFrame -nosound -vo pnm ${WORKDIR}$FILE1 >/dev/null |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
61 else |
16473 | 62 mplayer $FILE1_Options -nosound -vo pnm ${WORKDIR}$FILE1 > /dev/null |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
63 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
64 ### File 2 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
65 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
66 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
67 echo "############## $FILE2 #################" |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
68 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
69 cd ${TEMPDIR}/FILE2 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
70 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
71 rm *ppm 2> /dev/null |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
72 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
73 if [ $LastFrame -ge 0 ]; then |
16473 | 74 mplayer $FILE2_Options -frames $LastFrame -nosound -vo pnm ${WORKDIR}$FILE2 >/dev/null |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
75 else |
16473 | 76 mplayer $FILE2_Options -nosound -vo pnm ${WORKDIR}$FILE2 >/dev/null |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
77 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
78 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
79 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
80 ### PSNR |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
81 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
82 echo |
16473 | 83 echo "############## PSNR Calculation #################" |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
84 |
16473 | 85 if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` ]] |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
86 then |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
87 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
88 else |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
89 echo "Files have differing numbers of frames!" |
16473 | 90 echo "$FILE1 has `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` frames," |
91 echo "$FILE2 has `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames." | |
92 echo "Processing the first `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames." | |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
93 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
94 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
95 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
96 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
97 cd ${TEMPDIR}/FILE2 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
98 #rm ../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
99 echo "File;Y;Cb;Cr" >../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
100 echo "0" > errorsum.del |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
101 i=0 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
102 for FILE in `ls -1 *.ppm` |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
103 do |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
104 echo $FILE |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
105 echo -n "$FILE">>../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
106 echo -n ";">>../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
107 pnmpsnr ../FILE1/$FILE $FILE 2> del.del |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
108 grep "Y" del.del | dd bs=1c count=5 skip=29 of=del2.del 2>/dev/null |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
109 Y=`cat del2.del` |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
110 echo -n "$Y;">>../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
111 grep "Cb" del.del | dd bs=1c count=5 skip=29 of=del2.del 2>/dev/null |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
112 CB=`cat del2.del` |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
113 echo -n "$CB;">>../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
114 grep "Cr" del.del | dd bs=1c count=5 skip=29 of=del2.del 2>/dev/null |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
115 CR=`cat del2.del` |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
116 echo -n "$CR;">>../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
117 ALL=`echo "(-10)*l((e(-$Y/10*l(10))+e(-$CB/10*l(10))/4+e(-$CR/10*l(10))/4)/1.5)/l(10)"|bc -l` |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
118 echo "$ALL">>../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
119 ERROR=`echo "scale=30; (e(-1*$Y/10*l(10))+e(-1*$CB/10*l(10))/4+e(-1*$CR/10*l(10))/4)/1.5"|bc -l` |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
120 ERRORSUM=`cat errorsum.del` |
16473 | 121 echo `echo "scale=30; $ERROR + $ERRORSUM" | bc -l` > errorsum.del |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
122 i=$(($i+1)) |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
123 if [[ $i = $LastFrame ]] |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
124 then |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
125 break |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
126 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
127 done |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
128 ERRORSUM=`cat errorsum.del` |
16473 | 129 PSNR=`echo "-10*l($ERRORSUM/$i)/l(10)" | bc -l` |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
130 echo "PSNR:;$PSNR">>../psnr.dat |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
131 cd .. |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
132 mv psnr.dat ${WORKDIR} |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
133 |
16473 | 134 if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` ]] |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
135 then |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
136 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
137 else |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
138 echo "Files have differing numbers of frames!" |
16473 | 139 echo "$FILE1 has `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` frames," |
140 echo "$FILE2 has `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames." | |
141 echo "Processed the first `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames." | |
16462
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
142 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
143 fi |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
144 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
145 cd .. |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
146 rm -r ${TEMPDIR} |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
147 |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
148 echo "Created ${WORKDIR}psnr.dat" |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
149 echo |
fce59530dcfd
Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff
changeset
|
150 |