Exceptions
Every FFmpeg failure surfaces as a typed exception under FFmpeg\Exception\. Each one
carries the failing FFmpeg call and the decoded error text, so you never parse a message
string.
Properties (on every exception)
Section titled “Properties (on every exception)”| Property | Type | Description |
|---|---|---|
$operation | string | The FFmpeg API call that failed, e.g. "avcodec_open2". |
$avError | string | The av_strerror() text for the failing AVERROR, when there was one. |
getMessage() returns "{$operation}: {$avError}".
Hierarchy
Section titled “Hierarchy”FFmpegException (base — extends \Exception)├── FileNotFoundException input path did not exist├── InvalidFormatException opened but not valid/probeable media├── StreamNotFoundException a requested stream was not present├── EncoderNotFoundException chosen encoder not built into this FFmpeg└── EncodingException a failure during encoding / muxingCatch the base FFmpegException to handle everything, or a leaf for a specific case.
Example
Section titled “Example”use FFmpeg\Media;use FFmpeg\Exception\{FileNotFoundException, FFmpegException};
try { $media = Media::open($path);} catch (FileNotFoundException $e) { // handle a missing file specifically} catch (FFmpegException $e) { fprintf(STDERR, "ffmpeg failed in %s: %s\n", $e->operation, $e->avError);}An Artisan Build project.
Built on FFmpeg — an independent binding, not affiliated with or endorsed by the FFmpeg project.
Proudly sponsored by Tighten.