flutter_video_compress
flutter_video_compress copied to clipboard
[Bug] App crashes when compressing multiple videos using a for loop
Hi i want to compress a List of videos . So i tried to do this using a for in loop . But when compressing starts the app crashes . With one video only it works but with multiple videos it crashes . I use this with firebase storage . Here is my code :
for (File mediaFile in mediaFiles) {
final StorageReference _storageRef = FirebaseStorage.instance.ref();
String _mediaId = Uuid().v4();
final File _media = mediaFile.path.endsWith('.mp4')
? await compressVideo(mediaFile)
: await compressImage(_mediaId, mediaFile);
// Uploads user profile image
final StorageUploadTask _uploadTask = _storageRef
.child(
!mediaFile.path.endsWith('.mp4')
? '$path/$_mediaId.jpg'
: '$path/$_mediaId.mp4',
)
.putFile(_media);
final StorageTaskSnapshot _storageSnap = await _uploadTask.onComplete;
final String _downloadUrl = await _storageSnap.ref.getDownloadURL();
_mediaUrls.add(_downloadUrl);
}
return _mediaUrls;
}
And here is my video compression method :
static Future<File> compressVideo(File video) async {
final FlutterVideoCompress _videoCompress = FlutterVideoCompress();
final MediaInfo _compressedVideo = await _videoCompress.compressVideo(
video.path,
includeAudio: true,
);
return _compressedVideo.file;
}
Any help
same issues don't know how to solve it