iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🎨

How to disable automatic MP4 conversion when selecting videos with image_picker on iOS

に公開

When you select a video from the camera roll using Flutter's image_picker, it is converted to MP4 and saved.
Normal videos don't pose any particular issues, but on iPhones, HEVC (H.265) videos shot in HDR are sometimes passed. If these HEVC (H.265) videos are converted directly to H.264 SDR MP4, they appear washed out as it seems no tone mapping is applied.
To prevent this, I examined the iOS code for image_picker and modified the part responsible for the MP4 conversion.

packages/image_picker/image_picker_ios/ios/Classes/FLTImagePickerPlugin.m
Looking at line 232, you can see that it's coded to convert to MP4.

  imagePickerController.mediaTypes = @[
    (NSString *)kUTTypeMovie, (NSString *)kUTTypeAVIMovie, (NSString *)kUTTypeVideo,
    (NSString *)kUTTypeMPEG4
  ];

Delete the code after (NSString *)kUTTypeMovie,.

  imagePickerController.mediaTypes = @[(NSString *)kUTTypeMovie];

https://github.com/ioridev/plugins/commit/753103ea2a6c10fe4bea59f28a70585618a3fb0f

Now, videos can be selected in their original HDR format without being converted.

Also, since the video resolution would be reduced if left as is, please refer to this article as well.
https://zenn.dev/ioridev/articles/3fd5a5f583c131

Discussion