Prompt
transcode mp4 to hls api
Latest observation
Nov 1, 2026
OpenAI APIWeb search: off
If you want an API to transcode an MP4 into HLS, you typically use FFmpeg behind a web service.
Example FFmpeg command
ffmpeg -i input.mp4 \
-profile:v baseline -level 3.0 \
-start_number 0 \
-hls_time 10 \
-hls_list_size 0 \
-f hls \
output.m3u8
This generates:
output.m3u8playlist.tssegment files
Simple API design
A common endpoint might look like:
POST /transcode/hls
Request
file: uploaded MP4- optional:
segmentTimeresolutionbitrate
Response
{
"jobId": "abc123",
"status": "queued"
}
Backend flow
- Receive MP4 upload
- Save to temp storage
- Run FFmpeg
- Store HLS output
- Return playlist URL
Example Node.js Express API
import express from "express";
import multer from "multer";
import { exec } from "child_process";
import fs from "fs";
import path from "path";
const app = express();
const upload = multer({ dest: "uploads/" });
app.post("/transcode/hls", upload.single("file"), (req, res) => {
const inputPath = req.file.path;
const outputDir = `hls/${Date.now()}`;
fs.mkdirSync(outputDir, { recursive: true });
const outputPath = path.join(outputDir, "index.m3u8");
const cmd = `ffmpeg -i ${inputPath} -hls_time 10 -hls_list_size 0 -f hls ${outputPath}`;
exec(cmd, (err) => {
if (err) {
return res.status(500).json({ error: "Transcoding failed" });
}
res.json({
playlist: `/static/${outputDir}/index.m3u8`
});
});
});
app.use("/static", express.static("."));
app.listen(3000);
If you want a production-ready setup
Use:
- FFmpeg
- AWS S3 / GCS / Azure Blob for storage
- Job queue like BullMQ / Celery / Sidekiq
- CDN for delivery
If you want, I can give you:
- a Python FastAPI version,
- a Node.js production-ready version, or
- a Dockerized API for MP4 → HLS transcoding.