\seekquarry\yioop\library\media_jobsVideoConvertJob

Media Job used to convert videos uploaded to the wiki or group feeds to a common format (mp4)

Subclasses should implement methods they use among init(), checkPrerequisites(), nondistributedTasks(), prepareTasks(), finishTasks(), getTasks(), doTasks(), and putTask(). MediaUpdating can be configured to run in either distributed or nameserver only mode. In the former mode, prepareTasks(), finishTasks() run on the name server, getTasks() and putTask() run in the name server's web app, and doTasks() run on any MediaUpdater clients. In the latter mode, only the method nondistributedTasks() is called by the MediaUpdater and by only the updater on the name server.

Summary

Methods
Properties
Constants
__construct()
init()
run()
checkPrerequisites()
nondistributedTasks()
prepareTasks()
finishTasks()
doTasks()
getTasks()
putTasks()
execNameServer()
getJobName()
getCurrentMachine()
thumbFileFromVideo()
splitVideo()
splitVideos()
moveVideoFoldersToConvertedDirectory()
generateAssembleVideoFile()
mergeVideo()
concatenateVideos()
convertVideo()
$controller
$media_updater
$name_server_does_client_tasks
$name_server_does_client_tasks_only
$tasks
$video_convert_types
$db
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$controller

$controller : object

If MediaJob was instantiated in the web app, the controller that instatiated it

Type

object

$media_updater

$media_updater : object

If the MediaJob was instantiated in a MediaUpdater, this is a reference to that updater

Type

object

$name_server_does_client_tasks

$name_server_does_client_tasks : boolean

Whether to run the job's client tasks on the name server in addition to prepareTasks and finishTasks

Type

boolean

$name_server_does_client_tasks_only

$name_server_does_client_tasks_only : boolean

Whether this MediaJob performs name server only tasks

Type

boolean

$tasks

$tasks : array

The most recently received from the name server tasks for this MediaJob

Type

array

$video_convert_types

$video_convert_types : array

Supported file types of videos that we can convert to mp4.

Type

array

$db

$db : object

Datasource used to do directory level file manipulations (delete or traverse)

Type

object

Methods

__construct()

__construct(object  $media_updater = null, object  $controller = null) 

Instiates the MediaJob with a reference to the object that instatiated it

Parameters

object $media_updater

a reference to the media updater that instatiated this object (if being run in MediaUpdater)

object $controller

a reference to the controller that instantiated this object (if being run in the web app)

init()

init() 

Sets up the datasource used for the video convert directories

run()

run() 

Method executed by MediaUpdater to perform the MediaJob. This method shouldn't need to be overriden. Instead, the various callbacks it calls (listed in the class description) wshould be overriden.

checkPrerequisites()

checkPrerequisites() : boolean

Only run the VideoConvertJob if in distributed mode

Returns

boolean —

whether or not the prerequisites have been met for the job's tasks to be performed.

nondistributedTasks()

nondistributedTasks() 

Tasks done by this job when run in nondistributed mode

prepareTasks()

prepareTasks() 

Check for videos to convert. If found split to a common size to send to client media updaters. (Run on name server)

finishTasks()

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.

doTasks()

doTasks(array  $tasks) : 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.

Parameters

array $tasks

data that the MediaJob running on a client MediaUpdater needs to process

Returns

mixed —

the result of carrying out that processing

getTasks()

getTasks(integer  $machine_id, array  $data = null) : array

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.

Otherwise new file is sent for conversion along with its folder name.

Parameters

integer $machine_id

not used

array $data

not used

Returns

array —

an associate array with info on a file to convert

putTasks()

putTasks(integer  $machine_id, array  $data) : 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.

Parameters

integer $machine_id

id of client that is sending data to name server

array $data

results of computation done by client

Returns

string —

message concerning success or non-success of upload

execNameServer()

execNameServer(string  $command, string  $args = null) : array

Executes a method on the name server's JobController.

It will typically execute either getTask or putTask for a specific Mediajob or getUpdateProperties to find out the current MediaUpdater should be configured.

Parameters

string $command

the method to invoke on the name server

string $args

additional arguments to be passed to the name server

Returns

array —

data returned by the name server.

getJobName()

getJobName() : string

Gets the class name (less namespace and the word Job ) of the current MediaJob

Returns

string —

name of the current job

getCurrentMachine()

getCurrentMachine() : string

Returns a hash of the url of the current machine based on the value saved to current_machine_info.txt by a machine statuses request

Returns

string —

hash of current machine url

thumbFileFromVideo()

thumbFileFromVideo(string  $video_name, string  $thumb_name) 

Generates a thumbnail from a video file assuming FFMPEG

Parameters

string $video_name

full name and path of video file to make thumbnail from

string $thumb_name

full name and path for thumbnail file

splitVideo()

splitVideo(  $file_path,   $file_name,   $destination_directory) 

Splits a video into small chunks of 5 minutes

Parameters

$file_path
$file_name
$destination_directory

splitVideos()

splitVideos() 

Function to look through all the video directories present in media.

convert folder generated by group model.and split the eligible.files.

moveVideoFoldersToConvertedDirectory()

moveVideoFoldersToConvertedDirectory() 

Function to look through all the video directories present in media.

convert folder and move them to converted folders if all the split files. are converted and are present in video.directory.under.converted.

generateAssembleVideoFile()

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.

mergeVideo()

mergeVideo(  $text_file_name, string  $file_name, string  $destination_directory) 

Concatenates split video files to generate one video file

Parameters

$text_file_name
string $file_name

name of video file to be given to output file.

string $destination_directory

destination directory name where concatenated file would be produced

concatenateVideos()

concatenateVideos() 

Function to look.through each video directory and call the function to concatenate split files.

convertVideo()

convertVideo(string  $file_name) 

Function to convert avi or mov file to mp4 format.

Parameters

string $file_name

full path of the file.