numandev1 / react-native-compressor

🗜️Compress Image, Video, and Audio same like Whatsapp 🚀✨
MIT License
916 stars 86 forks source link

iPhone 16 Pro and Pro Max compression issues #313

Open paulsizer opened 1 day ago

paulsizer commented 1 day ago

Current behavior

I seem to be having issues compressing videos recorded on iPhone 16 Pro and 16 Pro Max devices that are in the high efficiency setting for capturing video. This videos are in a .mov video file.

If I record a video on my iPhone 14 Pro the video compresses as normal but when testing with a video recorded on the 16 Pro models and trying to compress it results in the exact same file being returned.

Screenshot 2024-10-11 at 13 36 12
 LOG  video_uri file:///Users/paul/Library/Developer/CoreSimulator/Devices/E1C94F32-6F84-4F57-81F3-A319169E3518/data/Containers/Data/Application/ECA070E0-4A5D-4BFA-8417-E22FBBEFFBBE/Library/Caches/ImagePicker/D3444CB1-7380-424B-ACBB-B55682266498.mov
 LOG  size 73619152
 LOG  compressedVideo file:///Users/paul/Library/Developer/CoreSimulator/Devices/E1C94F32-6F84-4F57-81F3-A319169E3518/data/Containers/Data/Application/ECA070E0-4A5D-4BFA-8417-E22FBBEFFBBE/Documents/D3444CB1-7380-424B-ACBB-B55682266498.mov
 LOG  compressedSize 73619152

Expected behavior

The file compresses to a MP4 file

Platform

React Native Version

0.74.1

React Native Compressor Version

1.9.0

Reproducible Steps And Demo

import { Video } from 'react-native-compressor';
import * as FileSystem from 'expo-file-system';

export const compressVideo = async (video_uri, onProgress) => {
  const uriParts = video_uri.split('/');
  const filename = uriParts[uriParts.length - 1];

  const newUri = `${FileSystem.documentDirectory}${filename}`;
  await FileSystem.copyAsync({
    from: video_uri,
    to: newUri,
  });
  const { size } = await FileSystem.getInfoAsync(video_uri);
  console.log('video_uri', video_uri);
  console.log('size', size);

  const compressedVideo = await Video.compress(
    newUri,
    { compressionMethod: 'manual',
      progressDivider: 10,
      minimumFileSizeForCompress: 1,
      maxFileSizeForCompress: 100,
      bitrateMultiplier: 0.8,
      compressQuality: 'medium', },
    (progress) => {
      const progressPercentage = parseInt(progress * 100);
      onProgress(progressPercentage);
    }
  );

  const { size: compressedSize } = await FileSystem.getInfoAsync(compressedVideo);
  console.log('compressedVideo', compressedVideo);
  console.log('compressedSize', compressedSize);

  return compressedVideo;
};
github-actions[bot] commented 1 day ago

👋 @paulsizer Thanks for opening your issue here! If you find this package useful hit the star🌟!