This page outlines the architectural patterns for building full-scale media applications using FFmpeg Kit Extended.
A standard converter app needs to handle file selection, parameter configuration, and background processing.
- State Management: Use
ProviderorBlocto track the list of tasks. - Service Layer: Create an
FFmpegServicethat wrapsFFmpegKit.executeAsync. - UI Components:
TaskCard: Shows progress, speed, and status for an individual conversion.SettingsPanel: Allows user to pick resolution, bitrate, and codec.
class ConversionTask {
final String input;
final String output;
double progress = 0;
SessionState state = SessionState.created;
void run() {
FFmpegKit.executeAsync(
'-i $input $output',
onStatistics: (s) => progress = calculateProgress(s),
onComplete: (s) => state = s.getState(),
);
}
}A media player that displays rich metadata and supports seeking.
- FFprobe Integration: Load metadata when the file is selected.
- FFplay UI: Use
FFplayKitfor the playback window and build a custom overlay for controls. - Background Audio: Use
audio_serviceplugin if you want the audio to continue when the app is minimized (FFmpeg Kit processes, but audio session management is standard Flutter).
void onLoadMedia(String path) async {
final session = await FFprobeKit.getMediaInformationAsync(path);
final info = session.getMediaInformation();
setState(() {
currentVideoTitle = info?.tags?['title'] ?? 'Unknown';
duration = parseDuration(info?.duration);
});
FFplayKit.execute(path);
}For apps like "Trimmer" or "Filter App" where the user sees a preview.
- Preview Engine: Use
FFplayKitto show a preview of the video at a specific timestamp. - Live Preview: When the user adjusts a slider (e.g., brightness), you can run a quick
FFmpegKitcommand to generate a thumbnail of that frame with the filter applied. - Exporting: Queue the final high-quality export using
executeAsync.
void onBrightnessChanged(double value) {
// Generate a thumbnail frame with current filter
FFmpegKit.execute(
'-ss $currentTime -i $input -vf "eq=brightness=$value" -vframes 1 preview.jpg'
);
// Update UI with preview.jpg
}- Power Management: Media processing is CPU intensive. Use
wakelockplugin to prevent the device from sleeping during long conversions. - Notification Integration: For long-running background tasks, use
flutter_local_notificationsto show progress in the system tray. - Storage Access: On Android 11+, ensure you are using Scope Storage correctly or have the
MANAGE_EXTERNAL_STORAGEpermission for arbitrary file access.