VideoConvertJob
extends MediaJob
in package
Media Job used to convert videos uploaded to the wiki or group feeds to a common format (mp4)
Table of Contents
- $controller : object
- If MediaJob was instantiated in the web app, the controller that instatiated it
- $db : object
- Datasource used to do directory level file manipulations (delete or traverse)
- $media_updater : object
- If the MediaJob was instantiated in a MediaUpdater, this is a reference to that updater
- $name_server_does_client_tasks : bool
- Whether to run the job's client tasks on the name server in addition to prepareTasks and finishTasks
- $name_server_does_client_tasks_only : bool
- Whether this MediaJob performs name server only tasks
- $tasks : array<string|int, mixed>
- The most recently received from the name server tasks for this MediaJob
- $video_convert_types : array<string|int, mixed>
- Supported file types of videos that we can convert to mp4.
- __construct() : mixed
- Instiates the MediaJob with a reference to the object that instatiated it
- checkPrerequisites() : bool
- Only run the VideoConvertJob if in distributed mode
- concatenateVideos() : mixed
- Function to look through each video directory and call the function to concatenate split files.
- convertVideo() : mixed
- Function to convert avi or mov file to mp4 format.
- doTasks() : mixed
- Called from run() with conversion tasks from name server. If there are any mov or avi segmentconverts them mp4 This function would only be called by client media updaters.
- execNameServer() : array<string|int, mixed>
- Executes a method on the name server's JobController.
- finishTasks() : mixed
- Checks if video convert task is complete for a video. If so, moves movie segments to a converted folder, assembles the segments into a single video file, and moves the result to the desired place.
- generateAssembleVideoFile() : mixed
- Function to look through all the converted video directories present in media and generate the assemble video files needed for concatenating the converted splitfiles.
- getCurrentMachine() : string
- Returns a hash of the url of the current machine based on the value saved to self::current_machine_info_file by a machine statuses request
- getJobName() : string
- Gets the class name (less namespace and the word Job ) of the current MediaJob
- getTasks() : array<string|int, mixed>
- Handles the request to get the video file from the video directory for conversion. This selection is based upon if the file was taken previously or not. If it was then its timestamp is checked.
- init() : mixed
- Sets up the datasource used for the video convert directories
- mergeVideo() : mixed
- Concatenates split video files to generate one video file
- moveVideoFoldersToConvertedDirectory() : mixed
- Function to look through all the video directories present in media.
- nondistributedTasks() : mixed
- Tasks done by this job when run in nondistributed mode
- prepareTasks() : mixed
- Check for videos to convert. If found split to a common size to send to client media updaters. (Run on name server)
- putTasks() : string
- Handles request to upload the posted data (video file data) in correct location as per the request attributes such as folder name and file name.
- run() : mixed
- Method executed by MediaUpdater to perform the MediaJob. This method shouldn't need to be overridden. Instead, the various callbacks it calls (listed in the class description) wshould be overridden.
- splitVideo() : mixed
- Splits a video into small chunks of 5 minutes
- splitVideos() : mixed
- Function to look through all the video directories present in media.
- thumbFileFromVideo() : mixed
- Generates a thumbnail from a video file assuming FFMPEG
Properties
$controller
If MediaJob was instantiated in the web app, the controller that instatiated it
public
object
$controller
$db
Datasource used to do directory level file manipulations (delete or traverse)
public
object
$db
$media_updater
If the MediaJob was instantiated in a MediaUpdater, this is a reference to that updater
public
object
$media_updater
$name_server_does_client_tasks
Whether to run the job's client tasks on the name server in addition to prepareTasks and finishTasks
public
bool
$name_server_does_client_tasks
$name_server_does_client_tasks_only
Whether this MediaJob performs name server only tasks
public
bool
$name_server_does_client_tasks_only
$tasks
The most recently received from the name server tasks for this MediaJob
public
array<string|int, mixed>
$tasks
$video_convert_types
Supported file types of videos that we can convert to mp4.
public
array<string|int, mixed>
$video_convert_types
= ["mov", "avi", "m2ts"]
Methods
__construct()
Instiates the MediaJob with a reference to the object that instatiated it
public
__construct([object $media_updater = null ][, object $controller = null ]) : mixed
Parameters
- $media_updater : object = null
-
a reference to the media updater that instatiated this object (if being run in MediaUpdater)
- $controller : object = null
-
a reference to the controller that instantiated this object (if being run in the web app)
Return values
mixed —checkPrerequisites()
Only run the VideoConvertJob if in distributed mode
public
checkPrerequisites() : bool
Return values
bool —whether or not the prerequisites have been met for the job's tasks to be performed.
concatenateVideos()
Function to look through each video directory and call the function to concatenate split files.
public
concatenateVideos() : mixed
Return values
mixed —convertVideo()
Function to convert avi or mov file to mp4 format.
public
convertVideo(string $file_name) : mixed
Parameters
- $file_name : string
-
full path of the file.
Return values
mixed —doTasks()
Called from run() with conversion tasks from name server. If there are any mov or avi segmentconverts them mp4 This function would only be called by client media updaters.
public
doTasks(array<string|int, mixed> $tasks) : mixed
Parameters
- $tasks : array<string|int, mixed>
Return values
mixed —the result of carrying out that processing
execNameServer()
Executes a method on the name server's JobController.
public
static execNameServer(string $command[, string $args = null ]) : array<string|int, mixed>
It will typically execute either getTask or putTask for a specific Mediajob or getUpdateProperties to find out the current MediaUpdater should be configured.
Parameters
- $command : string
-
the method to invoke on the name server
- $args : string = null
-
additional arguments to be passed to the name server
Return values
array<string|int, mixed> —data returned by the name server.
finishTasks()
Checks if video convert task is complete for a video. If so, moves movie segments to a converted folder, assembles the segments into a single video file, and moves the result to the desired place.
public
finishTasks() : mixed
Return values
mixed —generateAssembleVideoFile()
Function to look through all the converted video directories present in media and generate the assemble video files needed for concatenating the converted splitfiles.
public
generateAssembleVideoFile() : mixed
Return values
mixed —getCurrentMachine()
Returns a hash of the url of the current machine based on the value saved to self::current_machine_info_file by a machine statuses request
public
static getCurrentMachine() : string
Return values
string —hash of current machine url
getJobName()
Gets the class name (less namespace and the word Job ) of the current MediaJob
public
static getJobName() : string
Return values
string —name of the current job
getTasks()
Handles the request to get the video file from the video directory for conversion. This selection is based upon if the file was taken previously or not. If it was then its timestamp is checked.
public
getTasks(int $machine_id[, array<string|int, mixed> $data = null ]) : array<string|int, mixed>
Otherwise new file is sent for conversion along with its folder name.
Parameters
- $machine_id : int
-
not used
- $data : array<string|int, mixed> = null
-
not used
Return values
array<string|int, mixed> —an associate array with info on a file to convert
init()
Sets up the datasource used for the video convert directories
public
init() : mixed
Return values
mixed —mergeVideo()
Concatenates split video files to generate one video file
public
mergeVideo(string $text_file_name, string $file_name, string $destination_directory) : mixed
Parameters
- $text_file_name : string
-
file path containing.the relative file. paths of the files to be concatenated
- $file_name : string
-
name of video file to be given to output file.
- $destination_directory : string
-
destination directory name where concatenated file would be produced
Return values
mixed —moveVideoFoldersToConvertedDirectory()
Function to look through all the video directories present in media.
public
moveVideoFoldersToConvertedDirectory() : mixed
convert folder and move them to converted folders if all the split files. are converted and are present in video directory under converted.
Return values
mixed —nondistributedTasks()
Tasks done by this job when run in nondistributed mode
public
nondistributedTasks() : mixed
Return values
mixed —prepareTasks()
Check for videos to convert. If found split to a common size to send to client media updaters. (Run on name server)
public
prepareTasks() : mixed
Return values
mixed —putTasks()
Handles request to upload the posted data (video file data) in correct location as per the request attributes such as folder name and file name.
public
putTasks(int $machine_id, array<string|int, mixed> $data) : string
Parameters
- $machine_id : int
-
id of machine doing the put
- $data : array<string|int, mixed>
-
associative array about converted segment
Return values
string —message concerning success or non-success of upload
run()
Method executed by MediaUpdater to perform the MediaJob. This method shouldn't need to be overridden. Instead, the various callbacks it calls (listed in the class description) wshould be overridden.
public
run() : mixed
Return values
mixed —splitVideo()
Splits a video into small chunks of 5 minutes
public
splitVideo(string $file_path, mixed $file_name, string $destination_directory) : mixed
Parameters
- $file_path : string
-
full path of video file to be split
- $file_name : mixed
- $destination_directory : string
-
destination directory name where split files would be produced
Return values
mixed —splitVideos()
Function to look through all the video directories present in media.
public
splitVideos() : mixed
convert folder generated by group model and split the eligible files.
Return values
mixed —thumbFileFromVideo()
Generates a thumbnail from a video file assuming FFMPEG
public
thumbFileFromVideo(string $video_name, string $thumb_name) : mixed
Parameters
- $video_name : string
-
full name and path of video file to make thumbnail from
- $thumb_name : string
-
full name and path for thumbnail file