On Demand Video

Revision as of 09:32, 23 July 2021 by Connor.sanders (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is a brief overview of how the on-demand video system works.

Adding videos to the website

Main articles: Encode Server and EncodeSrv.

When attempting to add a video through the Watch section of the website 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 calendar year number, TRM is one of sum, spr or aut and YY is a term week number (10 for all weeks in a holiday up until week 1). 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 database 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.

EncodeSrv (running on the 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.