Skip to content

[ios] bitrate is ignored in compressVideo #3

Closed

Description

@FrikkieSnyman

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

Calling compressVideo with bitrate has no effect, since the bitrate parameter is completely unused in the compressVideo function in VideoProcessor.swift:

Library version

2.3.6

Environment info

System:
  OS: macOS 26.5.2                    Shell: zsh 5.9
Binaries:
  Node: 25.2.1    Yarn: 1.22.19    npm: 11.6.2    Watchman: 2026.07.27.00
Managers:
  CocoaPods: 1.17.0
SDKs:
  iOS SDK: iOS 26.5 (DriverKit 25.5, macOS 26.5, tvOS 26.5, visionOS 26.5, watchOS 26.5)
  Android SDK: API 23,26,30,32,33,34,35,36 | Build Tools 30.0.3–36.0.0 | NDK 29.0.14206865
IDEs:
  Xcode: 26.6/17F113    Android Studio: 2025.3
Languages:
  Java: 21.0.8    Ruby: 4.0.6
npmPackages:
  expo: 55.0.12    react: 19.2.0    react-native: 0.83.4    react-dom: 19.2.0
Android: hermesEnabled: true, newArchEnabled: true
iOS:     hermesEnabled: true (expo.jsEngine: hermes), newArch on by SDK default
Expo Workflow: bare
Device: iPhone 13 (iPhone14,5), iOS 26.2.1

Steps to reproduce

  1. Call MediaToolkit.compressVideo(result.uri, { bitrate: 4000000});
  2. Inspect resultant output file and note that bitrate is not 4000000

Reproducible example repository

n/a

Activity

  1. thangdevalone commented on Sep 15, 2026

    @thangdevalone
    Owner

    Thanks for reporting this! You're right - the bitrate parameter was completely unused in the iOS compressVideo implementation.

    The root cause: iOS used AVAssetExportSession which only supports Apple's built-in quality presets and doesn't accept custom bitrate values. The bitrate parameter was declared in the function signature but never actually referenced in the function body.

    Fixed in #4 by adding an AVAssetWriter + AVAssetReader pipeline that activates when bitrate > 0. This uses AVVideoAverageBitRateKey for precise H.264 bitrate control, matching the Android behavior.

  2. FrikkieSnyman commented on Oct 5, 2026

    @FrikkieSnyman
    Author

    @thangdevalone thanks for picking this up - are you planning on releasing this as a tagged release/published to NPM?

  3. thangdevalone commented on Oct 5, 2026

    @thangdevalone
    Owner

    @thangdevalone thanks for picking this up - are you planning on releasing this as a tagged release/published to NPM?

    @FrikkieSnyman
    Please check in v2.3.7: https://github.com/thangdevalone/react-native-media-toolkit/tree/v2.3.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions