The following assumes you have ffmpeg
installed on your Mac.
If you need to install it, please use Homebrew.
The settings for encoding for YouTube with ffmpeg can be found here and here.
There is no error checking here. It assumes that there are videos in the folder, and that they have mp4 extensions.