Guide

Convert a video to H.264 MP4 with an API

How do I convert any video to an MP4 that plays everywhere?

Encode to libx264 with AAC audio and add -movflags +faststart. That last flag moves the MP4 index to the front of the file so it starts playing before it has fully downloaded.

The ffmpeg command

What you would run locally, for reference.

ffmpeg -i input.mov \
  -c:v libx264 -preset medium -crf 23 \
  -c:a aac -b:a 128k \
  -movflags +faststart \
  output.mp4

The API request

The same flags, sent as JSON. Authenticate with Authorization: Token <your-api-token>.

POST /api/ffmpeg/job/
{
  "global_options": [
    "-y"
  ],
  "inputs": [
    {
      "input_source": "https://example.com/input.mov"
    }
  ],
  "outputs": [
    {
      "filename": "output.mp4",
      "options": [
        "-c:v",
        "libx264",
        "-preset",
        "medium",
        "-crf",
        "23",
        "-c:a",
        "aac",
        "-b:a",
        "128k",
        "-movflags",
        "+faststart"
      ]
    }
  ]
}

Worth knowing

  • Add -pix_fmt yuv420p when the source is ProRes or comes out of a camera: browsers can't decode the 4:2:2 pixel formats those often carry.
  • Without +faststart the file still plays, but only after the whole thing has downloaded — which looks like a broken player on a slow connection.

What it costs

Jobs bill in processing seconds — the CPU time this one actually uses — with a floor of 25 seconds per GB pulled out of storage to run it, so a stream-copy still counts. Uploading the output and downloading it afterwards are free. See the plans.

Related guides

Start free API reference

Ask me for anything

QuickFFmpeg is early and plenty is still missing. Tell me what you need and it goes straight to the top of my list.

This arrives anonymously. Log in first if you'd like an answer.