UNA
Loading...
Searching...
No Matches
BxDolTranscoderVideo Class Reference
Inheritance diagram for BxDolTranscoderVideo:
BxDolTranscoder iBxDolFactoryObject BxDolFactory iBxDolFactoryObject BxDolTranscoderAudio

Public Member Functions

 getDevicePixelRatioHandlerSuffix ()
 
 isMimeTypeSupported ($sMimeType)
 
 getFileUrlNotReady ($mixedHandler)
 
 isProcessHD ($sOrigVideoDim)
 
 getSize ($sFile)
 
- Public Member Functions inherited from BxDolTranscoder
 onDeleteFileLocal ($iFileId)
 
 onDeleteFileOrig ($mixedHandler)
 
 registerHandlers ()
 
 unregisterHandlers ()
 
 cleanup ()
 
 getStorage ()
 
 getDb ()
 
 getFileUrl ($mixedHandler)
 
 getFileUrlById ($mixedHandler)
 
 isFileReady ($mixedHandler, $isCheckOutdated=true)
 
 transcode ($mixedHandler, $iProfileId=0)
 
 prune ()
 
 forceDevicePixelRatio ($i)
 
 getDevicePixelRatio ()
 
 getOrigFileUrl ($mixedHandler)
 
 getTmpFilename ($sOverrideName=false)
 
 clearLog ()
 
 addToLog ($s)
 
 getLog ()
 
 deleteFromQueue ($mixedHandler)
 
 storeTranscodedFile ($mixedHandler, $sTmpFile, $iProfileId)
 
 getFilterParams ($sName)
 
 getMaxResizeDimention ($sFilter='Resize', $sKey='')
 
 isMobile ()
 

Static Public Member Functions

static getObjectAbstract ()
 
static getDuration ($sFile)
 
- Static Public Member Functions inherited from BxDolTranscoder
static getObjectInstance ($sObject)
 
static pruning ()
 
static processQueue ($bQueuePruning=true)
 
static pruneQueue ()
 
static processCompleted ()
 
static registerHandlersArray ($mixed)
 
static registerHandlersSystem ()
 
static unregisterHandlersArray ($mixed)
 
static cleanupObjectsArray ($mixed)
 
static onAlertResponseFileDeleteLocal ($oAlert, $sObject)
 
static onAlertResponseFileDeleteOrig ($oAlert, $sObject)
 

Protected Member Functions

 __construct ($aObject, $oStorage)
 
 applyFilter_Poster ($sFile, $aParams)
 
 applyFilter_Mp4 ($sFile, $aParams)
 
 applyFilter_Webm ($sFile, $aParams)
 
 _convertVideo ($sFile, $sFileOut, $sExt, $aParams, $aOptions)
 
 _getOptionSizeForVideo ($sFile, $aParams)
 
 _getFfmpegThreadsParams ()
 
- Protected Member Functions inherited from BxDolTranscoder
 storeTranscodedFileInQueueStorage ($mixedHandler, $sTmpFile, &$sFileUrlResult)
 
 addToQueue ($mixedHandler, $iProfileId=0)
 
 applyFilter_Resize ($sFile, $aParams)
 
 isFileReady_Folder ($mixedHandlerOrig, $isCheckOutdated=true)
 
 isFileReady_Storage ($mixedHandlerOrig, $isCheckOutdated=true)
 
 isPrivate_Folder ($mixedHandler)
 
 isPrivate_Storage ($mixedHandler)
 
 getFilePath_Folder ($mixedHandler)
 
 storeFileLocally_Folder ($mixedHandler)
 
 storeFileLocally_Storage ($mixedHandler)
 
 storeFileLocally_Queue ($mixedHandler)
 
 getOrigFileUrl_Folder ($mixedHandler)
 
 getOrigFileUrl_Storage ($mixedHandler)
 
 initFilters ()
 
 clearCacheDB ()
 
 processHandlerForRetinaDevice ($mixedHandler)
 

Additional Inherited Members

- Static Protected Member Functions inherited from BxDolTranscoder
static getTranscoderObjects ()
 
static _callFuncForObjectsArray ($mixed, $sFunc)
 
- Protected Attributes inherited from BxDolTranscoder
 $_sLog = ''
 
 $_aObject
 
 $_oStorage
 
 $_oDb
 
 $_sRetinaSuffix = '@2x'
 
 $_sQueueTable = ''
 
 $_sQueueStorage = ''
 
 $_iDevicePixelRatio = false
 

Detailed Description

This class transcodes videos and generates video thumbnails.

To generate video which plays in all moders browsers along with video poster, you need to create 3 different video transcoding objects which will generate .mp4, .webm videos and video poster. Video is converting upon first access, so it is probably better to force video conversion by calling

See also
BxDolTranscoderVideo\getFileUrl just after video uploading. Video for conversion is queued and when cron is run video conversion is performed. While video is pending for conversion or in the process then
BxDolTranscoderVideo\getFileUrl methods returns empty string for video and predefined image for video poster.

Transcoder object and other params are the same as in

See also
BxDolTranscoderImage, but it is highly recommended to disable 'atime_pruning' and 'atime_tracking', or set it to fairly big value, since video transcoding is not performed on the fly and takes some time.

Video conversion can be performed on separate server or multiple servers, to do it:

  • install the script on separate server(s), but connect to the same DB which your main site is using
  • enable 'sys_transcoder_queue_files' option (when it is enabled it takes a little longer to convert videos)
  • add the following code to the begining of inc/header.inc.php file on the main site, where your actual site in installed:
    define('BX_TRANSCODER_PROCESS_COMPLETED', '');
  • if you don't want your main site to convert videos, so all conversion will be performed on the separate server, add the following code to the begining of inc/header.inc.php file on the main site:
    define('BX_TRANSCODER_NO_TRANSCODING', '');
  • all servers must have different host name
  • only main server must be used as site, additional sites are just for video conversion, don't perform any action on these sites

Available filters:

  • Mp4 - this filter convert video into .mp4 format along with resizing, the parameters are the following:
    • h - height of resulted video (360px by default), for video it is highly recommended to specify only height parameter (without width parameter)
    • video_bitrate - video bitrate (512k by default)
    • audio_bitrate - video bitrate (128k by default)
    • ffmpeg_options - additional command line options for ffmepeg, as key => value array (empty by default)
  • Webm - this filter convert video into .webm format along with resizing, the parameters are the same as for Mp4 filter
  • Poster - this filter generates video thumbnail, it tries to get poster at 0, 3 and 5 seconds from the beginning, it gets first not fully black/white thumb

Example of usage:

// transcoder objects which generate .mp4, .webm videos and image poster
$oTranscoderMp4 = BxDolTranscoder::getObjectInstance('bx_video_mp4');
$oTranscoderWebm = BxDolTranscoder::getObjectInstance('bx_video_webm');
$oTranscoderPoster = BxDolTranscoder::getObjectInstance('bx_video_poster');
// make sure to call it only once (for example: during module installation), before the first usage, no need to call it every time
$oTranscoderMp4->registerHandlers();
$oTranscoderWebm->registerHandlers();
$oTranscoderPoster->registerHandlers();
// get URLs of transcoded videos and video thumbnail, 33 is ID of original video file stored in specified storage object
$sUrlMp4 = $oTranscoderMp4->getFileUrl(33);
$sUrlWebM = $oTranscoderWebm->getFileUrl(33);
$sUrlPoster = $oTranscoderPoster->getFileUrl(33);
echo 'My cat:' . BxTemplFunctions::getInstance()->videoPlayer($sUrlPoster, $sUrlMP4, $sUrlWebM);
static getObjectInstance($sObject)
Definition BxDolTranscoder.php:52

Also

See also
transcoder_videos sample for complete example.

Constructor & Destructor Documentation

◆ __construct()

BxDolTranscoderVideo::__construct ( $aObject,
$oStorage )
protected

constructor

Reimplemented from BxDolTranscoder.

Reimplemented in BxDolTranscoderAudio.

Member Function Documentation

◆ _convertVideo()

BxDolTranscoderVideo::_convertVideo ( $sFile,
$sFileOut,
$sExt,
$aParams,
$aOptions )
protected

Convert video using ffmpeg binary. Video conversion otput is written to the 'log' variable.

Parameters
$sFileinput file for conversion
$sFileOutoutput file for conversion, can be the same as input file
$sExtoutput file extension, in the format '.ext'
$aParamsfilter params
$aOptionsffmpeg options as array
Returns
false on error, or true on success

◆ _getOptionSizeForVideo()

BxDolTranscoderVideo::_getOptionSizeForVideo ( $sFile,
$aParams )
protected

Get output video size as 'WxH' string. It check filter params for 'w' and 'h' options and original video ratio and return the resulted video size.

  • If only height specified in params (desired behavior) or no width or height is specified (default height is 360), then width is automatically calculated using original video size ratio.
  • If only width specified in params, then height is automatically calculated using original video size ratio.
  • If width and height specified in params then these values are returned, but the resulted video size can be unproportionate.
    Parameters
    $sFileoriginal video file path (to check original video size ratio)
    $aParamsfilter params
    Returns
    WxH string

◆ applyFilter_Mp4()

BxDolTranscoderVideo::applyFilter_Mp4 ( $sFile,
$aParams )
protected

Convert video to .mp4 format

◆ applyFilter_Poster()

BxDolTranscoderVideo::applyFilter_Poster ( $sFile,
$aParams )
protected

Convert video to .jpg format - video poster

◆ applyFilter_Webm()

BxDolTranscoderVideo::applyFilter_Webm ( $sFile,
$aParams )
protected

Convert video to .webm format

◆ getDevicePixelRatioHandlerSuffix()

BxDolTranscoderVideo::getDevicePixelRatioHandlerSuffix ( )

Reimplemented from BxDolTranscoder.

◆ getFileUrlNotReady()

BxDolTranscoderVideo::getFileUrlNotReady ( $mixedHandler)

If video isn't processed yet then empty string is returned for video, or predefined image is returned for video poster

Reimplemented from BxDolTranscoder.

◆ getSize()

BxDolTranscoderVideo::getSize ( $sFile)

Get video size. It generated image from the video and returns size of the image.

Parameters
$sFilepath to the video file
Returns
array where 'w' key is width and 'h' key is height

◆ isMimeTypeSupported()

BxDolTranscoderVideo::isMimeTypeSupported ( $sMimeType)

check if transcoder suppors given file mime type

Reimplemented from BxDolTranscoder.

Reimplemented in BxDolTranscoderAudio.


The documentation for this class was generated from the following file: