Open krmao opened 8 months ago
ios crash on compress video
not crash
0.72.4
1.8.24
/** * https://github.com/numandev1/react-native-compressor/issues/217#issuecomment-1807184218 * @param fileUrl * @param compressVideoQuality */ const compressVideo = async (fileUrl: string, compressVideoQuality = 0.85): Promise<string> => { const originalVideoMetada = (await getVideoMetaData(fileUrl)) as any; const originalBitrate: number = originalVideoMetada.size / ((originalVideoMetada.duration / 60) * 0.0075); // sizeInKb / (minutes * 0.0075) const targetBitrate: number = Math.round(originalBitrate * compressVideoQuality); return await Video.compress( fileUrl, { progressDivider: 20, maxSize: 720, bitrate: targetBitrate, compressionMethod: 'manual', downloadProgress: progress => { console.log('> compressVideo download progress: ', progress); }, }, progress => { console.log('> compressVideo compress progress: ', progress); }, ); };
change
var bitRate=options["bitrate"] as! Float?;
to
var bitRate = (options["bitrate"] as? NSNumber)?.floatValue;
👋 @krmao Thanks for opening your issue here! If you find this package useful hit the star🌟!
Current behavior
ios crash on compress video
Expected behavior
not crash
Platform
React Native Version
0.72.4
React Native Compressor Version
1.8.24
Reproducible Steps And Demo
Quick fix
change
to