video_duration_native

Very Good Ventures Very Good Ventures

Developed with 💙 by Very Good Ventures 🦄

coverage style: very good analysis License: MIT

A lightweight native video duration reader for Flutter. Uses native platform APIs (MediaMetadataRetriever on Android, AVURLAsset on iOS) for fast metadata extraction. No FFmpeg, no byte loading.

Generated by the Very Good CLI 🤖

Features

✅ Lightweight - Native platform APIs only
✅ Fast - Metadata extraction without loading video into memory
✅ Cross-platform - Android and iOS support
✅ Content URI support - Android content:// URIs
✅ Type-safe - Returns Dart Duration object

Usage

import 'package:video_duration_native/video_duration_native.dart';

// Get duration from a file path
final duration = await getDuration('/path/to/video.mp4');
print('Duration: ${duration.inSeconds} seconds');

// Android content URI
final duration2 = await getDuration('content://media/external/video/123');

// Returns Duration.zero on error
final invalid = await getDuration('/invalid.mp4'); // Duration.zero

Platform Support

  • Android: File paths, content:// URIs
  • iOS: File paths, file:// URLs