Skip to content

FFmpegKit Protocols

Taner Sener edited this page Jul 28, 2026 · 2 revisions

FFmpegKitNext includes custom FFmpeg URL protocols for data that is not best handled as a normal filesystem path. These protocols are mostly hidden behind FFmpegKit API wrappers: you create a wrapper object, get a URL from it, pass that URL to an FFmpeg or FFprobe command, and close the wrapper when finished.

Use these protocols when you need one of these workflows:

  • Access an Android document picker URI
  • Pass bytes already held in memory to FFmpeg
  • Capture FFmpeg output directly into memory
  • Feed FFmpeg incrementally while a command is running
  • Read FFmpeg output incrementally while a command is running

Availability

Protocol Purpose Android Apple Linux Web Flutter React Native
ffkitsaf: Android Storage Access Framework documents yes no no no Android only Android only
ffkitmem: Seekable in-memory input/output yes yes yes yes yes yes
ffkitstream: Non-seekable streaming input/output yes yes yes yes yes yes

Flutter and React Native expose the native platform APIs. Their SAF helpers are therefore Android-only, while memory and stream helpers are available on their supported native platforms. Web exposes memory and stream helpers through the ffmpeg-kit-next-web JavaScript API.

Which Protocol To Use

Use ffkitsaf: when an Android user selects a document through the Storage Access Framework and you need to pass that content:// URI to FFmpegKit.

Use ffkitmem: when all input bytes are already in memory or when you want FFmpeg's complete output returned as bytes after the command finishes.

Use ffkitstream: when bytes are produced or consumed while FFmpeg is running. Streaming resources are not seekable, so they fit sequential formats and live pipelines.

General Pattern

The same pattern applies across platforms:

  1. Create the protocol wrapper.
  2. Pass getUrl() or the returned SAF URL to FFmpegKit.
  3. Run the FFmpeg or FFprobe command.
  4. Read or write data if the wrapper requires it.
  5. Close the wrapper or unregister the SAF URL when done.

Do not build protocol URLs manually. The numeric ids inside URLs refer to native resources registered by FFmpegKit, and those resources must be created and released through the API.

See

Clone this wiki locally