ffmpeg_streamer 0.1.0
ffmpeg_streamer: ^0.1.0 copied to clipboard
A cross-platform Flutter FFI plugin that embeds FFmpeg to decode audio & video and stream raw frames — works on Android, iOS, macOS, Windows & Linux.
ffmpeg_streamer #
A robust Flutter plugin for using FFmpeg to decode video and audio frames via FFI. Support for Android, iOS, macOS, Windows, and Linux.
Features #
- 🎥 Video Decoding: Access raw RGBA video frames.
- 🔊 Audio Decoding: Access raw Float32 audio samples.
- 🚀 Performance: Uses native FFmpeg with background thread decoding.
- 📱 Cross-Platform: Ready for all major Flutter platforms.
Prerequisites & Setup #
IMPORTANT: This plugin requires FFmpeg binaries. You must provide them due to licensing and size.
Android #
-
Download Android-compatible FFmpeg
.solibraries (e.g., from FFmpegKit or build yourself). -
Place them in your app's
android/source/main/jniLibs/<ABI>/or configure the pluginsrc/main/jniLibs. Required libraries:- libavformat.so
- libavcodec.so
- libavutil.so
- libswscale.so
- libswresample.so
Headers Place the FFmpeg include directories (libavcodec/, libavformat/, etc.) in:
android/src/main/cpp/include/So you should have
android/src/main/cpp/include/libavcodec/avcodec.h, etc.
iOS & macOS #
- iOS: Add a Pod dependency on an FFmpeg package or vend
ffmpeg.xcframeworkin your Podfile. - macOS: Ensure FFmpeg is installed via Homebrew (
brew install ffmpeg) or linked in yourmacos/Runner.xcodeproj. - The plugin looks for headers in standard
/usr/local/includeor/opt/homebrew/includeon macOS.
Windows #
- Set
FFMPEG_ROOTCMake variable or place FFmpeg headers/libs inwindows/ffmpeg. - Ensure
avcodec-*.dlletc. are in the same folder as your executable when running.
Linux #
- Install development packages:
sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev
Usage #
import 'package:ffmpeg_streamer/ffmpeg_streamer.dart';
void playVideo(String path) async {
final decoder = FfmpegDecoder();
await decoder.open(FfmpegMediaSource.fromFile(path));
// Get Info
final info = await decoder.mediaInfo;
print('Playing ${info.width}x${info.height} video');
// Listen to Frames
decoder.videoFrames.listen((frame) {
// Render frame.rgbaBytes (width x height x 4)
});
decoder.audioFrames.listen((frame) {
// Play frame.samples
});
await decoder.play();
}
License #
This plugin code is licensed under the MIT License. FFmpeg is licensed under LGPL or GPL. You are responsible for complying with the FFmpeg license in your final application.