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>.
{
"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 yuv420pwhen the source is ProRes or comes out of a camera: browsers can't decode the 4:2:2 pixel formats those often carry. - Without
+faststartthe 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.