VideoProcessor
in package
implements
AssetFormatProcessor
Video: the original goes to `/original/`, previews come from the first frame.
IMPORTANT: content verification is not best-effort. Without ffprobe, or with content that
ffprobe does not accept as MP4/MOV with a video track, the video is rejected and nothing is
written to disk.
The poster is best-effort: when ffmpeg is missing or extraction fails, the Asset is still created
(thumbnailsGenerated = false) and the catch-up cron fills in the variants
(AssetManager::backfillThumbnails()), which calls
renderPosterVariants(): the same code, not a copy.
Table of Contents
Interfaces
- AssetFormatProcessor
- Processes one format of an uploaded file: receives the bytes and the variant plan, writes files to disk and reports what was created.
Properties
Methods
- __construct() : mixed
- getExtensions() : array<int, string>
- Extensions (lowercase, without the dot) handled by the processor. They must be disjoint across processors; the registry reports a configuration error on a collision.
- getKind() : AssetFormatKind
- getMimeTypes() : array<int, string>
- MIME types matching {@see getExtensions()}; the uploaders build their `accept` attributes from them so that client and server stay in agreement.
- getVideoDimensions() : array{width: int, height: int}|null
- hasIsoBmffSignature() : bool
- ISO base media file format (`MP4`/`MOV`): the type of the first box lies at offset 4. New files start with `ftyp`, older QuickTime files also with `moov`/`mdat`/`wide`/`free`/`skip`/`pnot`.
- isAvailable() : bool
- Whether ffmpeg/ffprobe is available on the machine; without it poster variants are not created.
- process() : AssetProcessingResult
- renderPosterVariants() : array<string, array{width: int, height: int}>|null
- Extracts the first frame and runs it through the regular raster pipeline (resize and watermark).
Properties
$ffmpegService read-only
private
FfmpegService
$ffmpegService
$variantRenderer read-only
private
VariantRenderer
$variantRenderer
Methods
__construct()
public
__construct(FfmpegService $ffmpegService, VariantRenderer $variantRenderer) : mixed
Parameters
- $ffmpegService : FfmpegService
- $variantRenderer : VariantRenderer
getExtensions()
Extensions (lowercase, without the dot) handled by the processor. They must be disjoint across processors; the registry reports a configuration error on a collision.
public
getExtensions() : array<int, string>
Return values
array<int, string>getKind()
public
getKind() : AssetFormatKind
Return values
AssetFormatKindgetMimeTypes()
MIME types matching {@see getExtensions()}; the uploaders build their `accept` attributes from them so that client and server stay in agreement.
public
getMimeTypes() : array<int, string>
Return values
array<int, string>getVideoDimensions()
public
getVideoDimensions(string $videoPath) : array{width: int, height: int}|null
Parameters
- $videoPath : string
Return values
array{width: int, height: int}|nullhasIsoBmffSignature()
ISO base media file format (`MP4`/`MOV`): the type of the first box lies at offset 4. New files start with `ftyp`, older QuickTime files also with `moov`/`mdat`/`wide`/`free`/`skip`/`pnot`.
public
static hasIsoBmffSignature(string $data) : bool
Parameters
- $data : string
Return values
boolisAvailable()
Whether ffmpeg/ffprobe is available on the machine; without it poster variants are not created.
public
isAvailable() : bool
Return values
boolprocess()
public
process(AssetProcessingContext $context) : AssetProcessingResult
Parameters
- $context : AssetProcessingContext
Return values
AssetProcessingResultrenderPosterVariants()
Extracts the first frame and runs it through the regular raster pipeline (resize and watermark).
public
renderPosterVariants(string $videoPath, string $fileName, string $absBase, array<string, array{maxWidth?: int, maxHeight?: int, resizeFlags?: array, useWatermark?: bool}> $variantConfigs[, string $format = FfmpegService::FORMAT_MP4 ]) : array<string, array{width: int, height: int}>|null
Returns the real poster dimensions per variant, or null on any error (ffmpeg missing, timeout, corrupt video, unreadable frame).
Parameters
- $videoPath : string
- $fileName : string
- $absBase : string
-
$variantConfigs
: array<string, array{maxWidth?: int, maxHeight?: int, resizeFlags?: array
, useWatermark?: bool}> - $format : string = FfmpegService::FORMAT_MP4