<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMSampleBufferAttachmentKeyDefinitions/forceKeyFrame",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "s:9CoreMedia38CMSampleBufferAttachmentKeyDefinitionsO05forceF5Frame0A5Video012CVAttachmentF21DefinitionWithDefaultVyAE0K29ModePreferenceShouldPropagateOSbGvpZ"
  },
  "title" : "forceKeyFrame"
}
-->

# forceKeyFrame

Indicates that the current or next video sample buffer should be forced to be encoded as a key frame.

```
static let forceKeyFrame: CVAttachmentKeyDefinitionWithDefault<CMSampleBufferAttachmentKeyDefinitions.ShouldPropagate, Bool>
```

## Discussion

If this attachment is `true` on a sample buffer with a video frame, that video frame will be forced to become
a key frame. If the sample buffer for which this is `true` does not have a valid video frame, the next sample
buffer processed that contains a valid video frame will be encoded as a key frame. The getter returns the
default value of false if this attachment is not present.

Unless the origin and destination of a sample buffer is known, the general recommended practice is to synthesize
an empty sample buffer with this attachment alone and insert it into the sample buffer stream ahead of the
concrete sample buffer rather than setting this attachment on the concrete sample buffer itself.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)