<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaAccessibility",
  "identifier" : "/documentation/MediaAccessibility/MAFlashingLightsProcessor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Media Accessibility"
    ],
    "preciseIdentifier" : "c:objc(cs)MAFlashingLightsProcessor"
  },
  "title" : "MAFlashingLightsProcessor"
}
-->

# MAFlashingLightsProcessor

A class that processes a framebuffer object to detect and dim sequences of flashing lights.

```
class MAFlashingLightsProcessor
```

## Overview

A device with the Dim Flashing Lights setting on automatically dims the brightness of flashing effect sequences when it detects them in video content. If your app performs custom video drawing instead of using <doc://com.apple.documentation/documentation/AVFoundation> APIs, you can use the [`MAFlashingLightsProcessor`](/documentation/MediaAccessibility/MAFlashingLightsProcessor) class to detect and mitigate sequences of flashing effects in your video content.

The following example shows how you might incorporate [`MAFlashingLightsProcessor`](/documentation/MediaAccessibility/MAFlashingLightsProcessor) into code that uses <doc://com.apple.documentation/documentation/CoreVideo> APIs.

```swift
import MediaAccessibility
import CoreVideo
import OSLog

private let processor = MAFlashingLightsProcessor()
private let logger = Logger()

func readVideoBuffer() {
    
    // Confirm that the Dim Flashing Lights setting is on before processing video.
    if !MADimFlashingLightsEnabled() { return }

    // Retrieve the CVPixelBuffer from your video content.
    // ...
    
    // Get the IOSurface that backs the pixel buffer.
    guard let inSurface = CVPixelBufferGetIOSurface(pixelBuffer)?.takeUnretainedValue() else {
        logger.debug("Can't initialize input surface.")
        return
    }
    
    // Use the properties of the pixel buffer to initialize an output IOSurface.
    guard var outSurface = IOSurface(properties: [
        .width: CVPixelBufferGetWidth(pixelBuffer),
        .height: CVPixelBufferGetHeight(pixelBuffer),
        .bytesPerRow: CVPixelBufferGetWidth(pixelBuffer) * 4,
        .bytesPerElement: 4,
        .pixelFormat: CVPixelBufferGetPixelFormatType(pixelBuffer)
    ]) as IOSurfaceRef? else {
        logger.debug("Can't initialize output surface.")
        return
    }
    
    // Verify that the input IOSurface is compatible with the flashing lights processor.
    if processor.canProcessSurface(inSurface) {
        
        // Analyze input IOSurface for flashing light sequences
        // and write mitigated content to output IOSurface.
        let result = processor.processSurface(inSurface, outSurface: &outSurface,
                                              timestamp: CFAbsoluteTimeGetCurrent())
        
        if result.surfaceProcessed {
            logger.debug("""
            Processed content with flashing lights intensity \(result.intensityLevel)
            and mitigated output with mitigation level \(result.mitigationLevel).
            """)
            
            // Convert the mitigated output surface back to CVPixelBuffer
            // and draw the video content.
            // ...
            
        } else {
            logger.debug("Can't process input surface.")
        }
    }
}
```

For more information, see [Flashing lights](/documentation/MediaAccessibility/flashing-lights).

## Topics

### Checking compatibility

[`canProcessSurface(_:)`](/documentation/MediaAccessibility/MAFlashingLightsProcessor/canProcessSurface(_:))

Returns a Boolean value that indicates whether the flashing lights processor can process the content in the surface for sequences of flashing lights.

### Processing video content

[`processSurface(_:outSurface:timestamp:options:)`](/documentation/MediaAccessibility/MAFlashingLightsProcessor/processSurface(_:outSurface:timestamp:options:))

Processes a surface by analyzing pixels for sequences of flashing lights and mitigates them by dimming the content.

[`processSurface:outSurface:timestamp:options:`](/documentation/MediaAccessibility/MAFlashingLightsProcessor/processSurface:outSurface:timestamp:options:)

Processes a surface by analyzing pixels for sequences of flashing lights and mitigates them by dimming the content.

[`MAFlashingLightsProcessor.Result`](/documentation/MediaAccessibility/MAFlashingLightsProcessor/Result)

An object that reports the result of the flashing lights processor.

[`MAFlashingLightsProcessorResult`](/documentation/MediaAccessibility/MAFlashingLightsProcessorResult)

An object that reports the result of the flashing lights processor.

[`MAFlashingLightsProcessor.OptionKey`](/documentation/MediaAccessibility/MAFlashingLightsProcessor/OptionKey)

Options for the flashing lights processor.



---

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)