Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] App crashes when compressing multiple videos using a for loop #87

Open
Loopex2019 opened this issue Jun 3, 2020 · 2 comments
Open
Labels
bug Something isn't working

Comments

@Loopex2019
Copy link

Loopex2019 commented Jun 3, 2020

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;
  }
@Loopex2019 Loopex2019 added the bug Something isn't working label Jun 3, 2020
@Loopex2019
Copy link
Author

Any help

@duongtruong12
Copy link

duongtruong12 commented Jun 12, 2020

same issues don't know how to solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants