Closed dequidv closed 1 year ago
I'm experiencing the same issue on iOS with RN 0.70.4 and v1.6.4 of this library.
The video is remote (https). Can confirm that each thumbnail passes an accurate timestamp but each image draws the first frame of the video.
+1
Timestamp works for me, but the threshold is huge, so it misses a specific frame and captures a random frame in a range of 5-10 sec
I posted a PR that fixes this in my testing, but if anyone wants to use patch-package instead, this is what I've added:
diff --git a/node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m b/node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m
index 92cc49f..6bfa4a9 100644
--- a/node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m
+++ b/node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m
@@ -112,6 +112,8 @@ - (void) cleanDir:(NSString *)path forSpace:(unsigned long long)size {
- (void) generateThumbImage:(AVURLAsset *)asset atTime:(int)timeStamp completion:(void (^)(UIImage* thumbnail))completion failure:(void (^)(NSError* error))failure {
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
+ generator.requestedTimeToleranceAfter = CMTimeMake(0, 1000);
+ generator.requestedTimeToleranceBefore = CMTimeMake(0, 1000);
generator.appliesPreferredTrackTransform = YES;
generator.maximumSize = CGSizeMake(512, 512);
CMTime time = CMTimeMake(timeStamp, 1000);
Description No matter what timeStamp I put, it always create a thumbnail with the first frame. The thumbnail is rightfully created but not at the timeStamp I use. The timeStamp I try to put is equal to (video duration * 1000) / 2. The video used as reference is then played in react-native video library.
To Reproduce Steps to reproduce the behavior:
react-native-create-thumbnail
1.6.3react-native
: 0.68,Expected Results Describe what you expected to happen.
Snack, code example, screenshot, or link to a repository
Here is how I use the method createThumbnail
try { const response = await createThumbnail({ url: analysis?.data?.videoLocalUri, timeStamp: analysis?.data?.videoData?.duration ? (analysis?.data?.videoData?.duration * 1000) / 2 : 0, }); setThumbnail(response?.path); } catch (err) { console.error(err); } finally { setStatus('success'); setLoading(false); }