Tools
Eight simple endpoints that build the FFmpeg command for you.
Each tool is POST /v1/tools/<name> with a JSON body. They run on the same engine as Run FFmpeg.
curl "https://api.mediatofu.com/v1/tools/resize?wait=25" \
-H "Authorization: Bearer $MEDIATOFU_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "https://example.com/clip.mov", "width": 1280 }'Every tool takes these two fields, plus its own options below:
| Field | Required | Description |
|---|---|---|
input | Yes | A public URL or a file id. |
webhook_url | No | A URL to notify when the job finishes. Paid plans only. |
Options marked with a time accept seconds (90 or 1.5) or a timestamp (1:30 or 00:01:30.5).
probe
Reads a file's format and streams with ffprobe. The JSON appears in the job's result field. There are no options and no output files.
compress
Re-encodes video as H.264 with AAC audio at 128 kbps. Output: out.mp4.
| Option | Type | Range | Default |
|---|---|---|---|
crf | whole number | 18 to 40 | 28 |
max_height | whole number | 144 to 2160 | No scaling |
A lower crf means higher quality and a larger file. max_height caps the height and keeps the aspect ratio. Smaller videos aren't scaled up.
convert
Changes format. Output: out.<format>.
| Option | Type | Values | Default |
|---|---|---|---|
format | string | mp4, webm, mov, mkv, mp3, m4a, wav, ogg, flac | Required |
mp4, mov and mkv use H.264 and AAC at CRF 23. webm uses VP9 and Opus. Audio formats drop the video: mp3 is LAME at quality 2, m4a is AAC at 192 kbps, wav is 16-bit PCM, ogg is Vorbis at quality 5, and flac is lossless.
resize
Scales a video. Give width, height or both. If you give one, the other is set to keep the aspect ratio. Re-encodes as H.264 and AAC. Output: out.mp4.
| Option | Type | Range | Default |
|---|---|---|---|
width | whole number | 16 to 3840 | Unset |
height | whole number | 16 to 2160 | Unset |
trim
Cuts a section from a video or audio file without re-encoding, so cuts land on the nearest keyframes. The input must have one of the extensions listed under convert, or no extension, which is treated as mp4. Output: out.<ext>, the input's extension.
| Option | Type | Default |
|---|---|---|
start | time | 0 |
end | time | Unset, give this or duration |
duration | time | Unset, give this or end |
If you send both end and duration, end is used.
thumbnail
Saves one frame as a JPEG. Output: out.jpg.
| Option | Type | Range | Default |
|---|---|---|---|
at | time | Any | 0 |
width | whole number | 16 to 3840 | The video's width |
extract-audio
Pulls out the audio track. Output: out.<format>.
| Option | Type | Values | Default |
|---|---|---|---|
format | string | mp3, m4a, wav, ogg, flac | mp3 |
gif
Turns a section of video into an animated GIF. Output: out.gif.
| Option | Type | Range | Default |
|---|---|---|---|
start | time | Any | 0 |
duration | time | Any | 5 |
width | whole number | 16 to 1280 | 480 |
fps | whole number | 1 to 30 | 12 |
Option errors
Bad options return status 400 with a message naming the field, such as crf must be a whole number from 18 to 40. or format must be one of mp4, webm, mov, mkv, mp3, m4a, wav, ogg, flac. See Errors.