I have a script that detects crop values before I start video encoding. I do several probes at a certain interval, say every 100th frame. If all the crop values for all the probed frames match then there is no problem and the script kicks in the encoding function. If crop values differ then script exits with an error and I need to pick the correct crop value manually which is annoying.
So, instead of exiting the script with an error I would rather pick the "best" possible value which, in this situation, is the number that repeats the most.
So how do I pick a string out of the collection that repeats the most?
Say, I put all the crop values in an array. Crop=('3' '4' '3' '5' '7' '3' '7'); So in this situation I would pick value '3' as it repeats most often. How can I do it programmatically in Bash?
Thanks.
-- EDIT --
I do apologize, to simplify my question I might have confused some of you. The real crop values look like this "720:568:0:4".
(720:568:0:4 100:200:1:10 720:568:0:4 300:400:100:130)as well.