Prompt
How do I generate HLS and DASH streams from video files via API?
Latest observation
Nov 11, 2026
OpenAI APIWeb search: off
To generate HLS and DASH streams from video files via API, you typically do one of these:
- Use a video processing API/service that takes an uploaded video and returns HLS/DASH playlists and segments.
- Run your own transcoding pipeline with FFmpeg or a media packager, exposed through your API.
- Use a cloud media service that handles packaging and delivery automatically.
Typical API workflow
-
Upload source video
POST /uploadsor direct object storage upload.
-
Request streaming renditions
- Send source file URL or asset ID.
- Specify output formats:
- HLS:
.m3u8 - DASH:
.mpd
- HLS:
- Optionally specify multiple resolutions/bitrates.
-
Start processing job
- API returns a job ID.
-
Poll job status or receive webhook
GET /jobs/{id}- Or webhook callback when ready.
-
Fetch output URLs
- HLS master playlist URL
- DASH manifest URL
- Segment file URLs
Example API request
POST /transcode
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"input_url": "https://example.com/input/video.mp4",
"outputs": [
{
"format": "hls",
"renditions": [
{ "width": 426, "height": 240, "bitrate": 400000 },
{ "width": 854, "height": 480, "bitrate": 1200000 },
{ "width": 1280, "height": 720, "bitrate": 2500000 }
]
},
{
"format": "dash",
"renditions": [
{ "width": 426, "height": 240, "bitrate": 400000 },
{ "width": 854, "height": 480, "bitrate": 1200000 },
{ "width": 1280, "height": 720, "bitrate": 2500000 }
]
}
]
}
Response:
{
"job_id": "job_12345",
"status": "queued"
}
Example status response
{
"job_id": "job_12345",
"status": "completed",
"outputs": {
"hls": {
"master_url": "https://cdn.example.com/job_12345/master.m3u8"
},
"dash": {
"manifest_url": "https://cdn.example.com/job_12345/manifest.mpd"
}
}
}
If you’re implementing it yourself with FFmpeg
HLS
ffmpeg -i input.mp4 \
-map 0:v -map 0:a \
-c:v h264 -c:a aac \
-f hls \
-hls_time 6 \
-hls_playlist_type vod \
-hls_segment_filename "hls/seg_%03d.ts" \
hls/master.m3u8
DASH
ffmpeg -i input.mp4 \
-map 0:v -map 0:a \
-c:v h264 -c:a aac \
-f dash \
-seg_duration 6 \
dash/manifest.mpd
Then your API would:
- accept an input file
- trigger these commands in a worker/job queue
- upload outputs to storage/CDN
- return manifest URLs
Important considerations
- Codec support: HLS and DASH usually use H.264/AAC for broad compatibility.
- Segment duration: often 2–6 seconds.
- Adaptive bitrate ladders: create several resolutions/bitrates.
- Storage/CDN: host manifests and segments on object storage + CDN.
- Encryption/DRM: if needed, add AES-128 or DRM packaging.
- Webhooks: better than polling for long-running jobs.
Best practice API design
Use endpoints like:
POST /media→ create processing jobGET /media/{id}→ job status and output URLsPOST /webhooks→ optional completion callback
If you want, I can give you:
- a Node.js API example,
- a Python API example, or
- a complete FFmpeg-based backend design for HLS/DASH generation.
Brands