0

I want to get the original video file from photos in ios, when the user clicks on the video, the OS compresses the video and returns the compressed video to the app. I have these codes to pick a video with image_picker package:

final ImagePicker picker = ImagePicker();
final XFile? video = await picker.pickVideo(
source: ImageSource.gallery,
maxDuration: const Duration(seconds: 85),
preferredCameraDevice: CameraDevice.front,
);

Screenshot

How to disable compressing in ios?

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
Marlen Schreiner
  • 726
  • 10
  • 25

1 Answers1

-1

Once you have selected a video using the ImagePicker package, the selected video is returned as an XFile object which represents the compressed video file. To get the original video file, you need to access the path property of the XFile object and read the original file using the File class from the dart:io package.

import 'dart:io';
import 'package:image_picker/image_picker.dart';

final ImagePicker picker = ImagePicker();
final XFile? compressedVideo = await picker.pickVideo(
  source: ImageSource.gallery,
  maxDuration: const Duration(seconds: 85),
  preferredCameraDevice: CameraDevice.front,
);

if (compressedVideo != null) {
  final File originalVideo = File(compressedVideo.path!);
  // Use the original video file here...
}
Matic
  • 393
  • 3
  • 12
  • you put the XFile path into File. So, The File object is the same as the XFile object! – Marlen Schreiner Apr 07 '23 at 11:41
  • It's not. The path is the path to the video on iOS, not to the compressed video. It's the XFile that compresses the video at that path. You only use ImagePicker to get the actual filepath to the original video on your file system. – Matic Apr 07 '23 at 11:46
  • It's not working, do you test that on ios? – Marlen Schreiner Apr 07 '23 at 15:32