rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter. Support Asynchronous Now!
https://pub.dev/packages/opencv_dart
Apache License 2.0
136 stars 18 forks source link

[Bug] iOS Simulator VideoWriter not working correctly #213

Closed kreazyme closed 1 month ago

kreazyme commented 3 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior: I want to save a video to document directory by this code:


    final video1 = cv.VideoCapture.create(file1!.path);
    final double frameWidth = video1.get(3);
    final double frameHeight = video1.get(4);
    final double fps = video1.get(5);
    final path = await getApplicationDocumentsDirectory();
    final outputPath = '${path.path}${Platform.pathSeparator}videotest.mp4';
    final outputVideo = cv.VideoWriter.open(
      outputPath,
      'MJPG',
      fps,
      (
        frameWidth.toInt(),
        frameHeight.toInt(),
      ),
    );

I try to use imwrite inside video1.read(), the result is perfectly. But when i try to using outputVideo.write(frame), the video size is zero

Expected behavior Video save correctly

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

kreazyme commented 3 months ago

I tried to import both .MOV and .MP4 file, but nothing difference :(

kreazyme commented 3 months ago

The same issues in Android 13 Samsung physic device. I try to run VideoWriter many time but this code was not created this path. It seem like VideoWriter's bug

Evidence:

image

rainyl commented 3 months ago

get it. I finally managed to reproduce it. take a look at https://github.com/rainyl/awesome-opencv_dart/tree/main/examples/videoio first please.

image

I am not very familiar with android development, but I think it's because the permissions.

In the above example, when the destination path dst was selected manually from external storage (by clicking Save to), opencv complained that it cant find the path, but if we save to source file's parent directory directly, it worked fine.

rainyl commented 3 months ago

The same issues in Android 13 Samsung physic device. I try to run VideoWriter many time but this code was not created this path. It seem like VideoWriter's bug

Does the directory cache exists?

kreazyme commented 3 months ago

@rainyl In some minutes, I think the error like that. Then, I changed to download Directory, give permission,... but nothing happen. After that, I try to use cv.imwrite() to save an image and this working fine. I think the permission and directory has no problem. Thank for your reply :D and have nice day

rainyl commented 3 months ago

@kreazyme thx~

but i still have 2 questions: