The files are being written by Red5. So the user running Red5 needs to be able to write the files. To run on a port lower than 1024, by default you need root permissions I think. I am not an expert on that. But apache on your Moodle server will be just the same. So whatever is doable/acceptable there, should be possible on the Ubuntu server too.
The directory to which the files are written only needs to be owned or writeable by Red5.