Search by

ffmpeg-micro / ffmpeg-micro-php

ffmpeg-micro

Official PHP client for the FFmpeg Micro API: video transcoding, transcription and FFmpeg in the cloud.

v0.1.0 2026-10-19 20:09 UTC

This package is auto-updated.

Last update: 2026-10-19 20:21:38 UTC


README

The official PHP client for FFmpeg Micro: The FFmpeg API. FFmpeg Micro runs FFmpeg in the cloud: transcode and compress video, stitch clips, add text overlays, extract audio, generate thumbnails and transcribe speech through one API. There are no servers to manage and no FFmpeg builds to maintain.

composer require ffmpeg-micro/ffmpeg-micro-php

Requires PHP 8.1 or later.

Quickstart

Get an API key from the FFmpeg Micro dashboard. The free plan needs no credit card.

<?php
require 'vendor/autoload.php';

use FFmpegMicro\Api\DefaultApi;
use FFmpegMicro\Configuration;
use FFmpegMicro\Model\CreateTranscodeRequest;

$config = Configuration::getDefaultConfiguration()
    ->setAccessToken(getenv('FFMPEG_MICRO_API_KEY'));
$api = new DefaultApi(new GuzzleHttp\Client(), $config);

$job = $api->v1TranscodesPost(new CreateTranscodeRequest([
    'inputs' => [['url' => 'https://example.com/input.mov']],
    'outputFormat' => 'mp4',
    'preset' => ['quality' => 'high', 'resolution' => '1080p'],
]));

do {
    sleep(5);
    $job = $api->v1TranscodesIdGet($job->getId());
} while (in_array($job->getStatus(), ['pending', 'processing'], true));

if ($job->getStatus() !== 'completed') {
    throw new RuntimeException("Transcode {$job->getId()} ended as {$job->getStatus()}");
}

echo $api->v1TranscodesIdDownloadGet($job->getId())->getUrl();

Inputs can be public HTTP(S) URLs or your own files. To use a local file, call v1UploadPresignedUrlPost, PUT the file's bytes to the returned uploadUrl with any HTTP client (Guzzle works), then call v1UploadConfirmPost and pass the confirmed fileUrl as the input URL.

Pass options as plain arrays, the same way as inputs and preset above. A raw FFmpeg flag is ['option' => '-crf', 'argument' => '23'] and a text overlay is ['option' => '@text-overlay', 'argument' => ['text' => 'Hello']].

What it covers

Every endpoint in the FFmpeg Micro API:

  • Transcodes: create, list, get, cancel and download jobs, including multi-video compositions, raw FFmpeg options and @text-overlay
  • Uploads of your own files through presigned URLs
  • FFprobe media metadata for any input
  • Transcription of speech to text, with downloadable results
  • Blueprints, which are ready-made multi-step video pipelines
  • Generate endpoints for scenes, translation, images, speech and animation

Each method and model is documented in docs/. Method names follow the HTTP route (v1TranscodesPost is POST /v1/transcodes). Every method also has an ...Async variant that returns a Guzzle promise.

Notes

  • getSizeBytes() on a transcode input returns a decimal string on current jobs ("991017"), as the API sends it. Older jobs may return an integer. Cast with (int) before doing arithmetic.
  • Job status values are pending, processing, completed, failed and canceled. If the API adds an enum value this version of the package does not know yet, the getter returns unknown_default_open_api instead of throwing; upgrade the package to read it.

Errors

Failed calls throw FFmpegMicro\ApiException. getCode() is the HTTP status and getResponseBody() carries the API's error response.

How it is built

The client is generated with OpenAPI Generator from the OpenAPI spec the API itself serves. Each release is regenerated from the live spec, and ./generate.sh regenerates it. The full index of endpoints and models is in docs/README.md.

Links

MIT licensed.