This GitHub issue (#148464) discusses an error encountered while picking a video from the camera on Android tablets. Despite working on mobile phones, the video files saved from tablets have a size of 0 bytes. The problem, its context, and users’ attempts to resolve it are detailed below.
Table of Contents
Issue Details: Picking Video from Camera in Android Tablet
Title: Pick Video from Camera in Android Tablet (#148464)
Opened by: m-hamza-tanbits
Date Opened: 2 days ago
Comments: 5
Problem Description
User: m-hamza-tanbits
Steps to Reproduce
- Using the
image_picker
package to pick a video from the camera. - The process works correctly on mobile phones.
- On an Android tablet, creating a video and picking it results in a file size of 0 bytes.
- The image path is printed in the local cache, but when saving, the video file is 0 bytes.
Expected Results
The video file created from the camera should be saved with the correct file size. Picking Video from Camera in Android Tablet.
Actual Results
The video file is saved but with a size of 0 bytes.
Code Sample
final result = await picker.pickVideo(source: image_picker.ImageSource.camera);
Uint8List dataList = await result.readAsBytes();
log("file length ${dataList.length}"); // prints 0
print(result.path);
// The result prints: /storage/emulated/0/Movies/123 (2).mp4 to content://media/external_primary/video/media/1000000226
// While saving the file, it is saved as 0 bytes.
Screenshots or Video
- Screenshot/Video Demonstration
Logs
[log] data List data List 0
I/flutter ( 9733): result video path Instance of 'XFile'
D/MediaScannerConnection( 9733): Scanned /storage/emulated/0/Movies/123 (2).mp4 to content://media/external_primary/video/media/1000000226
Flutter Doctor Output
- Doctor Output: No
Comments and Suggestions for Picking Video from Camera in Android Tablet
@darshankawar (Member):
- Thank you for the report, @m-hamza-tanbits.
- Can you provide the Flutter version on which you see this error?
- Please provide a complete, runnable, reproducible code sample along with the plugin version.
- Are you using an Android tablet emulator or a physical device?
@m-hamza-tanbits (Author):
- Flutter Version: (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-x64, locale en-PK)
- Android Toolchain: Develop for Android devices (Android SDK version 34.0.0)
- Device: Physical Android tablet version 12
- Plugin Version: image_picker: ^1.1.1
Code Sample
import 'package:image_picker/image_picker.dart' as image_picker;
final image_picker.ImagePicker picker = image_picker.ImagePicker();
final image_picker.XFile? result = await picker.pickVideo(source: image_picker.ImageSource.camera);
log(result.path);
// Response: /storage/emulated/0/Movies/123 (2).mp4 to content://media/external_primary/video/media/1000000226
// When saving this file in the gallery or showing in a video player, it doesn't work because the file size is 0 bytes.
- Error: When saving the file, it saves as 0 bytes.
- Note: It works on Android phones. The error occurs on tablets.
@darshankawar (Member):
- I will try to verify this on a tablet emulator. Meanwhile, can you try using the plugin example on the same device to check if the issue persists?
- Since it is specific to tablets, check if there’s any setting causing the file size to be zero.
- Can you test with a native Android app to see if the same behavior occurs?
@m-hamza-tanbits (Author):
- Please verify.
- I have already used the plugin example. It works on both Android and iOS mobiles and on iOS tablets.
- The issue arises only on Android tablets.
- Tablet Version: 12
- Flutter Version: 3.19.6
- Package Version: image_picker: ^1.1.1
Also read:
What is New in Flutter: Support for WebAssembly (Wasm)
Google Introduces WebAssembly Support for Flutter and Dart
Issue Details Table in Content and Description Format
Content | Description |
---|---|
Title | Pick Video from Camera in Android Tablet (#148464) |
Opened By | m-hamza-tanbits |
Date Opened | 2 days ago |
Comments | 5 |
Join Our Whatsapp Group
Join Telegram group
Problem Description Table
Content | Description |
---|---|
User | m-hamza-tanbits |
Steps to Reproduce | 1. Using the image_picker package to pick a video from the camera. <br> 2. The process works correctly on mobile phones. <br> 3. On an Android tablet, creating a video and picking it results in a file size of 0 bytes. <br> 4. The image path is printed in the local cache, but when saving, the video file is 0 bytes. |
Expected Results | The video file created from the camera should be saved with the correct file size. |
Actual Results | The video file is saved but with a size of 0 bytes. |
Join Our Whatsapp Group
Join Telegram group
FAQs
What is the problem described in this issue?
The problem revolves around picking a video from the camera in an Android tablet using the image_picker
package. Despite working fine on mobile phones, when attempting the same process on an Android tablet, the resulting video file has a size of 0 bytes.
What are the expected results?
The expected outcome is for the video file created from the camera to be saved with the correct file size, similar to how it functions on mobile phones.
Why is the actual result different from the expected result?
Despite the video file being saved, it is observed that the file size is 0 bytes, which is not the intended outcome.
Can you provide a code sample illustrating the issue?
Certainly! Below is a code sample demonstrating the process:
final result = await picker.pickVideo(source: image_picker.ImageSource.camera);
Uint8List dataList = await result.readAsBytes();
log("file length ${dataList.length}"); // prints 0
print(result.path);
// The result prints: /storage/emulated/0/Movies/123 (2).mp4 to content://media/external_primary/video/media/1000000226
// While saving the file, it is saved as 0 bytes.
Is there any visual demonstration or evidence of the issue?
At the moment, there are no provided screenshots or videos showcasing the problem.
What does the log output reveal?
The log output indicates that the data list length is 0, and the result video path is an instance of ‘XFile’. Additionally, there’s a log indicating the scanning of the file path.
Is there any additional information regarding the Flutter environment?
Yes, the Flutter version being used is stable, with specific details provided about the Android toolchain and the physical Android tablet version being 12. The version of the image_picker
package being utilized is also mentioned.
Have any suggestions or troubleshooting steps been offered?
Yes, several suggestions and troubleshooting steps have been provided by the contributors involved. These include verifying the issue, testing with plugin examples, checking for settings causing the file size to be zero, and testing with a native Android app.
What is the current status of the investigation?
As of now, the issue remains unresolved. Further verification and testing are required to pinpoint the cause and provide a solution.