You appear to be the victim of what should be elegant programming !
It is of course all geared to how you want form your o/p.
Another part is looking up all the filemtime, combining an array then 'key' sorting.
filemtime is unreliable in that if you ever have edit / move / reupload your files everything will go a bit sick.
Regardless of all that, at some point you will need some sort of 'house-keeping' facility as the directory content gets larger and larger.
Short term at least the beteljuice suggests writing the options to a file.
the beteljuices main (XP) machine is at the vets getting life support at the moment - so totally untested and off the top of my head - something like:
<?php
$time_to_die = time() - (60 * 60 * 30); // 30hrs
if(isset($doit) || (filemtime('options.txt') < $time_to_die)) {
$files = glob("videos/*.mp4");
$files = array_combine(array_map("filemtime", $files), $files);
krsort($files);
foreach($files as $page){
$filename = basename($page,".mp4");
$option_list = "<option value = 'wxvideodisp.php?src=" .$page. "'>" .$filename. "</option>\n";
}
file_put_contents('options.txt', $options_list);
}
?>
<form>
<select name="s1" onChange="window.open(this.options[this.selectedIndex].value,'_blank')">
<option value="wxwebcamvid.php" selected="selected">Select a date</option>
<?php include "options.txt"; ?>
</select>
</form>
To avoid errors you must initially create an empty file called options.txt on your server.
Then the first time you 'call' your page
add ?doit=1 to the url.
That
should create populate the include file that creates the drop down list - this is also the routine you would do every day
after you've done a new archive file.
If you forget, then if the options.txt file is older than 30 hours is will be rebuilt (while the viewer has to wait)
Totally untested, may be silly errors so create a test page first !!!!!
If that all works, the next thing will be the 'picking' method - the beteljuice has a thought or two on that