iTranslated by AI
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];
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.
Discussion