I have no idea what you're doing in your code, since you haven't shown us any!
But here's a bit of code that will list all directories of a given folder, hopefully you can take it as inspiration for your own code.
<?php
function scan_videos(&$array, $path)
{
$files = glob($path.'/*');
foreach ($files as $file)
{
if (is_dir($file))
{
$array[] = $file;
scan_videos($array, $file);
}
}
}
$directories = array();
scan_videos($directories, 'videos');
print_r($directories);
?>
This will output
Array
(
[0] => videos/1137
[1] => videos/1137/0
[2] => videos/1137/1
[3] => videos/1137/2
[4] => videos/1137/3
[5] => videos/1137/4
)