#! /bin/sh # durdist - compute and print the distribution of video frame # durations in # # This is a mickey mouse script to help look at the behavior of variable frame # rate video encoding. It requires that the mpeg4ip tool "mp4videoinfo" be # somewhere in the current path. mp4videoinfo "$1" | awk '/^sampleId/ { ts = int( substr($6, 1, index($6, "(") - 1)*90000/48000 + 0.5 ) if (++totalFrames > 1) ++nframes[ts - l]; l = ts } END { # group the frame lengths into classes for (i in nframes) { fclass = int(i/100) class[i] = fclass csum[fclass] += nframes[i] wsum += i * nframes[i] / totalFrames } # compute the weighted average length for each class for (i in nframes) { fclass = int(i/100) cwsum[fclass] += i * nframes[i] / csum[fclass] } printf "ticks number %%total\n" for (i in cwsum) { printf "%d %6d %5.1f%%\n", int(cwsum[i]+0.5), csum[i], csum[i]*100/totalFrames } printf "average frame %d ticks (%.3f fps)\n", int(wsum + 0.5), 90000/wsum }' | sort -n