mobile bluesky app made with flutter lazurite.stormlightlabs.org/
mobile bluesky flutter
at main 51 lines 1.3 kB view raw
1import 'dart:io'; 2 3import 'package:video_player/video_player.dart'; 4 5class VideoProcessor { 6 VideoProcessor(); 7 8 Future<VideoMetadata> extractMetadata(String videoPath) async { 9 final file = File(videoPath); 10 if (!file.existsSync()) { 11 throw StateError('Video file not found: $videoPath'); 12 } 13 14 final controller = VideoPlayerController.file(file); 15 try { 16 await controller.initialize(); 17 18 return VideoMetadata( 19 durationSeconds: controller.value.duration.inSeconds, 20 width: controller.value.size.width.toInt(), 21 height: controller.value.size.height.toInt(), 22 ); 23 } finally { 24 await controller.dispose(); 25 } 26 } 27 28 bool isVideoMimeType(String mimeType) { 29 return mimeType.startsWith('video/'); 30 } 31} 32 33class VideoMetadata { 34 const VideoMetadata({required this.durationSeconds, required this.width, required this.height}); 35 36 final int durationSeconds; 37 final int width; 38 final int height; 39 40 Map<String, dynamic> toJson() { 41 return {'width': width, 'height': height}; 42 } 43 44 static VideoMetadata fromJson(Map<String, dynamic> json) { 45 return VideoMetadata( 46 durationSeconds: json['durationSeconds'] as int, 47 width: json['width'] as int, 48 height: json['height'] as int, 49 ); 50 } 51}