On Demand Video
This is a brief overview of how the on-demand video system works.
Adding Videos to the Website
When attempting to add a video the user is presented with a list of files in the Finished Shows folder to choose from. They select a source file, named following the convention XX_title_TRM_YY where XX is the year number, TRM is one of sum, spr or aut and YY is a week number. The website does some checks, for example making sure the file actually obeys the naming scheme, and then generates a series of entries in the encode_jobs table. As part of this process, the web server runs ffmpeg -i on the file to get some metadata, and selects appropriate target formats. For historical reasons, Finished Shows is actually mounted in /mnt/UserData as it was easier to do this than change the site code.
The Encode Server periodically checks for entries in the encode_jobs table, sets their status to waiting and begins copying the files to a local directory, before attempting to run an encode job on them. When the job is complete it copies the resulting output to target directories specified by the website when creating the job. Conveniently, these are all under /data/video which is on the webserver and mounted under this location to the encode server as well.
The website will not allow public-facing access to any video which does not have a file that has finished encoding and been copied.
Thumbnail Generation
The Thumbnails button on an internal watch page runs an ffmpeg command on the playout video to generate a handful of thumbnails scattered through the file. Naturally if the video server, which stores the playout versions, is offline this won't work, nor if the encode has not succeeded for any reason.
Watching Videos on the Website
JW Player on the site is presented with a video file in the form ystv.co.uk/videostream/watch/IDNO where IDNO is the video file's ID number. The pseudostreaming software, Loomiere receives these requests via an Apache rewrite, and runs a small PHP script (videohit.php) to mark a hit in the database, before delivering the actual video file based on the ID number given.