rurico / flutter_video_compress

Generate a new file by compressed video, and provide metadata. Get video thumbnail from a video path, supports JPEG/GIF. To reduce app size not using FFmpeg in IOS.
MIT License
188 stars 73 forks source link

[Bug] subsequent calls to getThumbnail rewrite the previous thumbnail #64

Open lukepighetti opened 5 years ago

lukepighetti commented 5 years ago

If you call getThumbnailWithFile multiple times it will rewrite the previous thumbnail. This makes it difficult to generate a film-strip, as the consumer of flutter_video_compress would have to copy and rename the file after each iteration, and await each thumbnail process instead of batching them.

    print(info.duration);
    final markers = List<int>.generate(count, (i) => (duration.inSeconds * (i / count)).round());
    print(markers);
    final futures =
        markers.map((seconds) => _compressor.getThumbnailWithFile(file.path, quality: 40, position: seconds));
    final results = await Future.wait(futures);
    print(results.map((file) => file.path));
flutter: 26926.666666666664
flutter: [0, 3, 6, 9, 12, 14, 17, 20, 23]
flutter: (
/private/var/mobile/Containers/Data/Application/27D7AAA9-B308-4730-9BE8-AB946661E8B7/tmp/flutter_video_compress/FEB63F13-5FA6-4BAC-8C05-FF68ACB43BFC.jpg, 
/private/var/mobile/Containers/Data/Application/27D7AAA9-B308-4730-9BE8-AB946661E8B7/tmp/flutter_video_compress/FEB63F13-5FA6-4BAC-8C05-FF68ACB43BFC.jpg,
 /private/var/mobile/Containers/Data/Application/27D7AAA9-B308-4730-9BE8-AB946661E8B7/tmp/flutter_video_compress/FEB63F13-5FA6-4BAC-8C05-FF68ACB43BFC.jpg, 
...,
 /private/var/mobile/Containers/Data/Application/27D7AAA9-B308-4730-9BE8-AB946661E8B7/tmp/flutter_video_compress/FEB63F13-5FA6-4BAC-8C05-FF68ACB43BFC.jpg, 
/private/var/mobile/Containers/Data/Application/27D7AAA9-B308-4730-9BE8-AB946661E8B7/tmp/flutter_video_compress/FEB63F13-5FA6-4BAC-8C05-FF68ACB43BFC.jpg
)
lukepighetti commented 5 years ago

As a note for others running into the same use case, I suggest using getThumbnail and MemoryImage instead! Works wonderfully. Leaving this open for now, as I still think it could be an improvement to have getThumnailWithFile return unique files

festapp86 commented 4 years ago

Is this also solving the problem, when you want to have multiple thumbnails of a video in the same second (after each 300 ms)?