---
title: "HLS Encoding: Segment Length, Keyframes and Renditions"
description: "Learn HLS encoding: choose segment lengths, align keyframes, create renditions, and use FFmpeg to encode video for reliable streaming."
image: https://blog.blazingcdn.com/hubfs/Gemini-Blog/image-Oct-01-2026-07-30-24-1875-AM.jpeg
---

[![BlazingCDN](https://blog.blazingcdn.com/hubfs/Logo/blog-logo-w.png)](https://blog.blazingcdn.com?hsLang=en-us)

[📘Learn ▾](https://blog.blazingcdn.com/cdn-learn?hsLang=en-us)

[CDN Fundamentals](https://blog.blazingcdn.com/cdn-fundamentals?hsLang=en-us) [By Content Type](https://blog.blazingcdn.com/by-content-type?hsLang=en-us) [Advanced Concepts](https://blog.blazingcdn.com/advanced-concepts?hsLang=en-us) [Glossary](https://blog.blazingcdn.com/glossary?hsLang=en-us)

[⚡ Web Performance](https://blog.blazingcdn.com/web-performance?hsLang=en-us)

[🎬Video & Streaming ▾](https://blog.blazingcdn.com/video-streaming-cdn?hsLang=en-us)

[🔴 Live Streaming](https://blog.blazingcdn.com/live-streaming?hsLang=en-us) [📺 VOD & OTT](https://blog.blazingcdn.com/vod-ott?hsLang=en-us) [💰 Bandwidth & Costs](https://blog.blazingcdn.com/bandwidth-costs?hsLang=en-us)

[🏭 Other Industries ▾](https://blog.blazingcdn.com/cdn-industry-insights?hsLang=en-us)

[📺 Media & Broadcasting](https://blog.blazingcdn.com/media-broadcasting?hsLang=en-us) [💾 Software & SaaS](https://blog.blazingcdn.com/software-saas?hsLang=en-us) [🏗️ DevOps & Cloud Infra](https://blog.blazingcdn.com/devops-cloud-infra?hsLang=en-us) [📚 AdTech & Advertising](https://blog.blazingcdn.com/adtech-advertising?hsLang=en-us) [🎮 Gaming & Esports](https://blog.blazingcdn.com/gaming-esports?hsLang=en-us) [📱 Mobile Apps & Developers](https://blog.blazingcdn.com/mobile-apps-developers?hsLang=en-us) [🤖 AI & Machine Learning](https://blog.blazingcdn.com/ai-machine-learning?hsLang=en-us) [🏛️ Enterprise & Corporate](https://blog.blazingcdn.com/enterprise-corporate?hsLang=en-us) [📚 E-Learning & EdTech](https://blog.blazingcdn.com/e-learning-edtech?hsLang=en-us) [🏟️ Sports & Live Events](https://blog.blazingcdn.com/sports-live-events?hsLang=en-us)

[💰 Pricing & Costs ▾](https://blog.blazingcdn.com/cdn-pricing-and-cdn-costs?hsLang=en-us)

[Provider Pricing](https://blog.blazingcdn.com/provider-pricing?hsLang=en-us) [Cost Optimization](https://blog.blazingcdn.com/cost-optimization?hsLang=en-us) [Decision Support](https://blog.blazingcdn.com/decision-support?hsLang=en-us)

[⚡Compare ▾](https://blog.blazingcdn.com/cdn-comparison?hsLang=en-us)

[Provider Comparisons](https://blog.blazingcdn.com/provider-comparisons?hsLang=en-us) [Strategy Comparisons](https://blog.blazingcdn.com/strategy-comparisons?hsLang=en-us) [Ratings & Benchmarks](https://blog.blazingcdn.com/cdn-ratings-and-benchmarks?hsLang=en-us)

[📊 Benchmarks](https://blog.blazingcdn.com/cdn-ratings-and-benchmarks?hsLang=en-us)

[🔒 Security ▾](https://blog.blazingcdn.com/cdn-security?hsLang=en-us)

[Attack Protection](https://blog.blazingcdn.com/attack-protection?hsLang=en-us) [Encryption & Access](https://blog.blazingcdn.com/encryption-access?hsLang=en-us) [Video & DRM Security](https://blog.blazingcdn.com/video-drm-security?hsLang=en-us)

[📁 Case Studies](https://blog.blazingcdn.com/case-studies?hsLang=en-us) [🔌 Integrations](https://blog.blazingcdn.com/integrations?hsLang=en-us) [🛠️ Tools](https://blog.blazingcdn.com/cdn-tools?hsLang=en-us)

[Get Started](https://blazingcdn.com/sign-up-contact-form/)

[Learn](https://blog.blazingcdn.com/en-us/tag/learn) [Video - VOD & OTT](https://blog.blazingcdn.com/en-us/tag/video-vod-ott) [Learn - CDN Fundamentals](https://blog.blazingcdn.com/en-us/tag/learn-cdn-fundamentals)

# HLS Encoding: Segment Length, Keyframes and Renditions

 BlazingCDN  Oct 1, 2026, 9:32:44 AM

![](https://blog.blazingcdn.com/hubfs/Gemini-Blog/image-Oct-01-2026-07-30-24-1875-AM.jpeg)

HLS encoding that plays smoothly comes down to three linked numbers: a segment target duration, a fixed keyframe interval that divides it exactly, and a rendition ladder in which every rung places keyframes at the same timestamps. This playbook walks through each setting with the exact ffmpeg flags and values, then shows how to validate the output. Expect 60 to 90 minutes from a mezzanine file to a validated, multi-rendition fMP4 package.

As of 2026, Apple's HLS authoring specification recommends a 6-second target segment duration with a keyframe every 2 seconds, which is 48 frames at 24 fps or 60 frames at 30 fps. Every rendition in the ladder must share those keyframe positions, or players stall and show visual glitches when they switch bitrates.

## **What HLS segment length should you use?**

Use 6 seconds for video on demand and 2 to 4 seconds for standard-latency live. A 6-second HLS segment length keeps request counts and per-segment overhead low. Shorter segments start playback faster and adapt sooner, but each one must begin on a keyframe, so you pay for extra IDR frames in bitrate and in object count.

The trade-off is quantifiable. A 2-hour film cut into 6-second segments produces 1,200 segments per rendition. With five video renditions and one audio rendition that is 7,200 objects. At 2-second segments the same title becomes 21,600 objects, three times the request rate against the edge and three times the playlist length the player parses.

Live latency moves in the opposite direction. Most players hold about three segments before starting, so 6-second segments put a viewer roughly 18 seconds or more behind the encoder, while 2-second segments bring that down to about 6 to 8 seconds. If you need sub-5-second glass-to-glass latency, plain HLS segments are the wrong tool, and Low-Latency HLS (LL-HLS) partial segments are the next step.

## **Prerequisites**

- ffmpeg 6.x or 7.x built with libx264 and the native AAC encoder. Run ffmpeg with the -version flag and confirm both libraries appear in the configuration line.
- ffprobe from the same build, used for keyframe validation.
- A mezzanine source at constant frame rate. Variable frame rate sources, common in screen recordings and phone footage, make keyframe timing drift; normalize them first with the fps video filter.
- Optionally, Apple's mediastreamvalidator and hlsreport tools for a spec-level check of the finished package.
- A test player such as hls.js or Safari with network throttling, for forcing rendition switches.

## **Step 1: derive the keyframe interval from the segment length**

Pick the segment duration first, then set the Group of Pictures (GOP) so that a whole number of GOPs fits inside each segment. The rule is simple: GOP frames equal frame rate times GOP seconds, and the segment duration must be an exact multiple of the GOP duration.

The matrix below is the worked arithmetic for common frame rates with a 2-second GOP, which divides 4-second and 6-second segments evenly.

| Frame rate | GOP (2 s) in frames | GOPs per 4 s segment | GOPs per 6 s segment |
| --- | --- | --- | --- |
| 24 fps | 48 | 2 | 3 |
| 25 fps | 50 | 2 | 3 |
| 30 fps | 60 | 2 | 3 |
| 29.97 fps | 60 (actual GOP 2.002 s) | 2 (4.004 s) | 3 (6.006 s) |
| 50 fps | 100 | 2 | 3 |
| 60 fps | 120 | 2 | 3 |

Fractional rates such as 29.97 fps are the only case where segment durations drift above the nominal value, so fix the GOP in frames rather than in seconds for those sources.

Why it matters: the ffmpeg HLS muxer can only cut a segment at a keyframe. If the GOP does not divide the target, the muxer waits for the next keyframe, and a 6-second target turns into a sequence of 6, 8 and 10-second segments that inflate EXT-X-TARGETDURATION and the player's buffer requirement.

## **Step 2: lock keyframes across every rendition with ffmpeg**

Keyframe alignment means the IDR frame at, say, 12.000 seconds exists in the 1080p, 720p and 360p outputs alike. The default x264 behavior breaks this, because scene-cut detection inserts extra keyframes wherever the picture changes, and those decisions differ by resolution. Set these flags on every video output:

| ffmpeg flag | Value (30 fps source) | Why |
| --- | --- | --- |
| -g | 60 | Maximum GOP length of 2 seconds |
| -keyint\_min | 60 | Prevents shorter GOPs |
| -sc\_threshold | 0 | Disables scene-cut keyframes that differ per rung |
| -force\_key\_frames | expr:gte(t,n\_forced\*2) | Pins IDR frames to exact 2-second timestamps |
| -bf | 2 or 3 | B-frames stay legal inside closed GOPs |

The force\_key\_frames expression is the safety net: even if the frame rate wobbles, IDR frames land on time-based boundaries that match across renditions.

If you encode renditions in separate ffmpeg processes or on separate machines, these flags are what keep them aligned. Encoding all rungs in one process with the split filter is simpler and guarantees an identical input timeline.

## **Step 3: build the rendition ladder**

A rendition ladder is the set of resolution and bitrate pairs listed in the multivariant playlist. Space adjacent rungs roughly 1.5 to 2 times apart in bitrate so the player has a meaningful step down under congestion without jumping straight to an unwatchable rung. The H.264 values below are starting points for typical live-action content at 30 fps, not tuned numbers.

| Rung | Resolution | Target video bitrate | maxrate / bufsize |
| --- | --- | --- | --- |
| 1 | 1920x1080 | 6,000 kbps | 6,600k / 12,000k |
| 2 | 1280x720 | 3,000 kbps | 3,300k / 6,000k |
| 3 | 960x540 | 1,600 kbps | 1,760k / 3,200k |
| 4 | 640x360 | 800 kbps | 880k / 1,600k |
| 5 | 416x234 | 300 kbps | 330k / 600k |

Capping maxrate at about 110% of target keeps the measured peak close to the BANDWIDTH attribute, which is what players use to choose a rung.

Use capped VBR (target bitrate with -b:v, plus -maxrate and -bufsize) rather than uncapped CRF. Uncapped CRF lets a high-motion segment spike to three times the advertised bitrate, and a player that trusted BANDWIDTH will rebuffer. Encode audio once as 128 kbps stereo AAC at 48 kHz and reference it from every variant instead of duplicating it per rung.

## **Step 4: how to encode video for HLS with the ffmpeg HLS muxer**

The ffmpeg hls muxer writes media playlists, segments and the multivariant playlist in one pass. These are the packaging flags that matter for a VOD title in fMP4 segments:

1. **-f hls** selects the HLS muxer.
2. **-hls\_time 6** sets the target segment duration. Segments are cut at the first keyframe at or after this point, which is why Step 1 matters.
3. **-hls\_playlist\_type vod** writes a complete playlist with EXT-X-ENDLIST, so players can seek across the whole title.
4. **-hls\_segment\_type fmp4** produces CMAF-compatible fragmented MP4 segments, required for HEVC in HLS and reusable for DASH.
5. **-hls\_fmp4\_init\_filename init.mp4** names the initialization segment that carries codec parameters.
6. **-hls\_flags independent\_segments** adds EXT-X-INDEPENDENT-SEGMENTS, telling the player every segment starts with a keyframe.
7. **-master\_pl\_name master.m3u8** writes the multivariant playlist with BANDWIDTH, RESOLUTION and CODECS attributes.
8. **-var\_stream\_map** groups outputs into variants, for example "v:0,agroup:aud v:1,agroup:aud v:2,agroup:aud a:0,agroup:aud" so every video rung shares one audio group.
9. **-hls\_segment\_filename** takes a pattern containing ffmpeg's variant token (percent sign followed by v) and a zero-padded sequence token (percent sign, 03d), which puts each rung in its own directory.

For live, swap -hls\_playlist\_type vod for a sliding window: -hls\_list\_size 6 with -hls\_flags delete\_segments plus independent\_segments, and drop -hls\_time to 2 with a 1-second or 2-second GOP.

## **Validating HLS encoding output before it ships**

Check three things: keyframe positions, segment durations and declared versus measured bitrate. Each has an expected value you can compare against in minutes.

- **Keyframe timestamps:** run ffprobe on the 1080p and 360p outputs with -skip\_frame nokey and -show\_entries frame=pts\_time on the video stream. Both lists must read 0, 2, 4, 6 and so on, identical to the millisecond.
- **Segment durations:** every EXTINF value in each media playlist should equal 6.000 (or 6.006 for 29.97 fps), except the final segment. EXT-X-TARGETDURATION should read 6.
- **Bitrate:** run mediastreamvalidator, then hlsreport. Measured peak bitrate should sit within about 10% of BANDWIDTH; larger gaps mean your maxrate is too loose.
- **Switching:** play the master playlist in Safari or hls.js, throttle the network from 10 Mb/s to 1 Mb/s and back, and watch for frozen frames or audio pops at the switch point.
- **Cache headers:** fetch a segment and a VOD playlist from your edge with a HEAD request. Segments should be long-lived (a max-age of days or longer); live media playlists should expire within roughly half a segment duration.

## **Rollback**

Write every new ladder to a versioned path, such as a directory named after the encode profile and date, and never overwrite segments in place. Rollback is then a one-line change to which multivariant playlist your player or manifest service points at. Overwriting segments under the same URLs is the mistake to avoid: edges will serve a mix of old and new segments until caches expire, and mismatched init segments break playback outright.

## **Failure modes: symptom, cause, fix**

- **Frozen frame or green flash on bitrate switch.** Cause: scene-cut keyframes differ per rendition. Fix: -sc\_threshold 0 plus force\_key\_frames on every rung.
- **Segments alternate between 6 and 10 seconds.** Cause: GOP does not divide hls\_time, or the source has variable frame rate. Fix: recompute the GOP from the matrix in Step 1 and normalize the frame rate.
- **Player sits on low rungs despite a fast connection.** Cause: BANDWIDTH overstated, or peak spikes trigger downswitching. Fix: capped VBR and a bufsize near 2 times target.
- **Audio gaps at segment boundaries.** Cause: muxed audio in MPEG-TS with AAC priming offsets. Fix: a separate audio rendition in fMP4.
- **Live latency of 20 seconds or more.** Cause: 6-second live segments times a three-segment player buffer. Fix: 2-second segments, or LL-HLS partial segments.

## **Tuning once it works**

Start with 6 seconds and move to 4 only if startup time or switch responsiveness is a measured problem. Each halving of segment duration doubles IDR frames per minute; at low bitrates that typically costs a few percent of compression efficiency, which shows up as visible softness on the bottom rungs.

Then tune the ladder to the content. Animation and slide-based lectures look clean at roughly half the bitrates in the table, while sports needs more headroom at 720p and above. Per-title encoding, where you run test encodes and choose rungs from a quality metric such as VMAF, is the logical next step once the pipeline is stable.

Delivery cost follows these choices too, because 2-second segments triple the object count per title. BlazingCDN's [**HLS Streaming CDN for pre-encoded HLS and LL-HLS**](https://blazingcdn.com/streaming-cdn/) serves the packaged segments with unlimited requests and no request fees, but it does not transcode, so the encoding steps above stay in your pipeline.

## **FAQ: HLS encoding, segment length and keyframes**

### What is the best HLS segment length for video on demand?

Six seconds is the standard HLS segment length for video on demand. It keeps object counts and playlist size manageable while giving players enough segments to adapt. Shorter segments, such as 2 or 4 seconds, improve startup and switching speed but add IDR frames, which raises bitrate at equal quality and triples requests at 2 seconds.

### How do I align keyframes across HLS renditions in ffmpeg?

Set the same fixed GOP on every rendition and disable scene-cut detection. In ffmpeg that means matching -g and -keyint\_min values, -sc\_threshold 0, and a time-based force\_key\_frames expression. Encoding all renditions in a single ffmpeg process with the split filter also guarantees every rung reads an identical input timeline.

### Why are my ffmpeg HLS segments longer than hls\_time?

The ffmpeg HLS muxer can only cut segments at keyframes, so segments run long when the GOP does not divide hls\_time. A 6-second target with a 5-second GOP produces 10-second segments. Variable frame rate sources cause the same drift. Fix the GOP in frames and convert the source to constant frame rate before encoding.

### Should HLS encoding use fMP4 or MPEG-TS segments?

Use fMP4 for new HLS encoding pipelines. Fragmented MP4 segments are required for HEVC in HLS, work with CMAF so the same segments can serve DASH, and avoid MPEG-TS overhead. Keep MPEG-TS only for legacy devices that predate fMP4 support, and confirm that requirement against your actual player analytics first.

## **Run the alignment check, then test delivery on real segments**

This week, pull one title from your existing catalog and run the ffprobe keyframe check against its top and bottom renditions. If the timestamp lists differ, you have found the cause of switch glitches your QoE dashboards attribute to the network. Then compute the object count per title at your current segment length and at 2 seconds, and compare it with your edge request bill and cache hit ratio, since that number decides whether shorter segments are affordable.

If your packaged HLS library is ready for a new delivery layer, the [**BlazingCDN OTT and VOD streaming CDN**](https://blazingcdn.com/ott-vod-streaming-cdn/) page covers how it serves pre-encoded segments, and a 14-day testing period on real production traffic is available for that comparison.

Share: [f](https://www.facebook.com/sharer/sharer.php?u=https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions) [in](https://www.linkedin.com/sharing/share-offsite/?url=https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions) [𝕏](https://twitter.com/intent/tweet?url=https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions&text=) [✉](mailto:?subject=%3Cspan%20id="hs_cos_wrapper_name"%20class="hs_cos_wrapper%20hs_cos_wrapper_meta_field%20hs_cos_wrapper_type_text"%20style=""%20data-hs-cos-general-type="meta_field"%20data-hs-cos-type="text"%20%3EHLS%20Encoding:%20Segment%20Length,%20Keyframes%20and%20Renditions%3C/span%3E&body=https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions)

![BlazingCDN](https://blog.blazingcdn.com/hs-fs/hubfs/Logo/blog-logo-w.png?height=24&name=blog-logo-w.png)

*Heavy traffic.*  
Light bill.

The CDN for video and large traffic

Their monthly bill vs ours

- 20 TBFastly $2,087**$92.50**
- 50 TBCDN77 $990**$215**
- 200 TBCloudFront $11,965**$765**

Published list prices, Aug 2026

[Calculate your cost](https://blazingcdn.com/cdn-cost-calculator/?utm_source=blog&utm_medium=sidebar&utm_campaign=blog_sidebar&utm_content=compare_calc)

## Related posts

[![](https://blog.blazingcdn.com/hubfs/Gemini-Blog/image-Oct-01-2026-07-00-29-8623-AM.jpeg)](https://blog.blazingcdn.com/en-us/cdn-js-best-practices-minification-versioning-cache-bust-rules?hsLang=en-us)

Learn

### [CDN JavaScript Best Practices: Versioning and Cache Busting](https://blog.blazingcdn.com/en-us/cdn-js-best-practices-minification-versioning-cache-bust-rules?hsLang=en-us)

Cache busting changes a JavaScript file's URL whenever its content changes, so browsers and CDN edges fetch the new ...

Oct 1, 2026, 9:02:50 AM [Read more](https://blog.blazingcdn.com/en-us/cdn-js-best-practices-minification-versioning-cache-bust-rules?hsLang=en-us)

[![](https://blog.blazingcdn.com/hubfs/Gemini-Blog/image-Sep-30-2026-01-16-22-5421-PM.jpeg)](https://blog.blazingcdn.com/en-us/content-delivery-network-pricing-models-compared-2025-edition?hsLang=en-us)

Pricing - Pricing & Costs

### [CDN Pricing Models Compared: Per GB, Commit, Flat Rate and Tiers](https://blog.blazingcdn.com/en-us/content-delivery-network-pricing-models-compared-2025-edition?hsLang=en-us)

Content delivery network pricing spans roughly a 17x range at the same volume. On published price lists checked August ...

Sep 30, 2026, 3:19:29 PM [Read more](https://blog.blazingcdn.com/en-us/content-delivery-network-pricing-models-compared-2025-edition?hsLang=en-us)

[![BlazingCDN](https://blog.blazingcdn.com/hubfs/Logo/blog-logo-w.png)](https://blog.blazingcdn.com?hsLang=en-us)

[📘 Learn](https://blog.blazingcdn.com/cdn-learn?hsLang=en-us) [📊 Benchmarks](https://blog.blazingcdn.com/cdn-ratings-and-benchmarks?hsLang=en-us) [🎬 Video & Streaming](https://blog.blazingcdn.com/video-streaming-cdn?hsLang=en-us) [🏭 Industries](https://blog.blazingcdn.com/cdn-industry-insights?hsLang=en-us) [💰 Pricing & Costs](https://blog.blazingcdn.com/cdn-pricing-and-cdn-costs?hsLang=en-us) [⚡ Compare](https://blog.blazingcdn.com/cdn-comparison?hsLang=en-us) [🔒 Security](https://blog.blazingcdn.com/cdn-security?hsLang=en-us) [🛠️ Tools](https://blog.blazingcdn.com/cdn-tools?hsLang=en-us) [✍️ Publish with us](https://blog.blazingcdn.com/publish-with-us?hsLang=en-us)

in f 𝕏 ✉

 Copyright © BlazingCDN |. All rights reserved.

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://blazingcdn.com/#organization",
  "@type" : "Organization",
  "description" : "High-volume CDN for video, live streaming, OTT/IPTV, software, games, SaaS and large-file delivery.",
  "logo" : {
    "@id" : "https://blazingcdn.com/#logo",
    "@type" : "ImageObject",
    "height" : 560,
    "url" : "https://blazingcdn.com/wp-content/uploads/2024/08/logo-560-560.png",
    "width" : 560
  },
  "name" : "BlazingCDN",
  "sameAs" : [ "https://www.linkedin.com/company/68261278", "https://x.com/BlazingCdn", "https://twitter.com/BlazingCdn", "https://www.facebook.com/BlazingCDN", "https://www.reddit.com/r/BlazingCDN/" ],
  "url" : "https://blazingcdn.com/"
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://blog.blazingcdn.com/#website",
  "@type" : "WebSite",
  "inLanguage" : "en-US",
  "name" : "BlazingCDN Blog",
  "publisher" : {
    "@id" : "https://blazingcdn.com/#organization"
  },
  "url" : "https://blog.blazingcdn.com/"
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions#article",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "BlazingCDN"
  },
  "dateModified" : "2026-10-01T07:32:45Z",
  "datePublished" : "2026-10-01T07:32:44Z",
  "description" : "Learn HLS encoding: choose segment lengths, align keyframes, create renditions, and use FFmpeg to encode video for reliable streaming.",
  "headline" : "HLS Encoding: Segment Length, Keyframes and Renditions",
  "image" : "https://143144902.fs1.hubspotusercontent-eu1.net/hubfs/143144902/Gemini-Blog/image-Oct-01-2026-07-30-24-1875-AM.jpeg",
  "inLanguage" : "en-us",
  "isPartOf" : {
    "@id" : "https://blog.blazingcdn.com/#website"
  },
  "mainEntityOfPage" : {
    "@id" : "https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@id" : "https://blazingcdn.com/#organization"
  },
  "wordCount" : 2242
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions#breadcrumb",
  "@type" : "BreadcrumbList",
  "itemListElement" : [ {
    "@type" : "ListItem",
    "item" : "https://blog.blazingcdn.com/en-us",
    "name" : "Blog",
    "position" : 1
  }, {
    "@type" : "ListItem",
    "item" : "https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions",
    "name" : "HLS Encoding: Segment Length, Keyframes and Renditions",
    "position" : 2
  } ]
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://blog.blazingcdn.com/en-us/hls-encoding-segment-length-keyframes-and-renditions#faq",
  "@type" : "FAQPage",
  "mainEntity" : [ {
    "@type" : "Question",
    "acceptedAnswer" : {
      "@type" : "Answer",
      "text" : "Six seconds is the standard HLS segment length for video on demand. It keeps object counts and playlist size manageable while giving players enough segments to adapt. Shorter segments, such as 2 or 4 seconds, improve startup and switching speed but add IDR frames, which raises bitrate at equal quality and triples requests at 2 seconds."
    },
    "name" : "What is the best HLS segment length for video on demand?"
  }, {
    "@type" : "Question",
    "acceptedAnswer" : {
      "@type" : "Answer",
      "text" : "Set the same fixed GOP on every rendition and disable scene-cut detection. In ffmpeg that means matching -g and -keyint_min values, -sc_threshold 0, and a time-based force_key_frames expression. Encoding all renditions in a single ffmpeg process with the split filter also guarantees every rung reads an identical input timeline."
    },
    "name" : "How do I align keyframes across HLS renditions in ffmpeg?"
  }, {
    "@type" : "Question",
    "acceptedAnswer" : {
      "@type" : "Answer",
      "text" : "The ffmpeg HLS muxer can only cut segments at keyframes, so segments run long when the GOP does not divide hls_time. A 6-second target with a 5-second GOP produces 10-second segments. Variable frame rate sources cause the same drift. Fix the GOP in frames and convert the source to constant frame rate before encoding."
    },
    "name" : "Why are my ffmpeg HLS segments longer than hls_time?"
  }, {
    "@type" : "Question",
    "acceptedAnswer" : {
      "@type" : "Answer",
      "text" : "Use fMP4 for new HLS encoding pipelines. Fragmented MP4 segments are required for HEVC in HLS, work with CMAF so the same segments can serve DASH, and avoid MPEG-TS overhead. Keep MPEG-TS only for legacy devices that predate fMP4 support, and confirm that requirement against your actual player analytics first."
    },
    "name" : "Should HLS encoding use fMP4 or MPEG-TS segments?"
  } ]
}
```