fluttercandies / flutter_photo_manager

A Flutter plugin that provides images, videos, and audio abstraction management APIs without interface integration, available on Android, iOS, macOS and OpenHarmony.
https://pub.dev/packages/photo_manager
Apache License 2.0
688 stars 314 forks source link

[BUG] Some of the videos not showing in picker #646

Closed NaikSoftware closed 2 years ago

NaikSoftware commented 2 years ago

Describe the bug I use this library for a long time for images, but recently I tried to enable videos and some of users reported that cant see some videos, but can see in other apps like Facebook that also use MediaStore.

How to reproduce Enable common or videos filter and open picker.

Version information

Additional context All not displayed videos are screencasts recorded by built in firmware recorder. When user sends "broken" video to any place (original without modification) and download on device again - it displayed. So the file is valid. Especially since all native apps show this file sucessfully. Can somehow suggest where to search the error? Maybe additional filters in picker or filters in underlying media manager (MediaStore), or consumed crash when getting preview can cause this.

AlexV525 commented 2 years ago

Try ignoreSize in the filter option for videos and see if it works?

NaikSoftware commented 2 years ago

@AlexV525 I tried to ignore all filters but it has no effect

Gallery (and messenger's pickers) vs Wechat Asset Picker

Light         Dark

image

AlexV525 commented 2 years ago

Any info for these videos? Are they different from regular videos? Like different extensions (.hevc, .m3u8, etc) or something else?

NaikSoftware commented 2 years ago

@AlexV525 these mp4 videos recorded by built in screen recorder. As I described at start - if user send it to any place (original, without re-encoding) and download again then it displayed in wechat picker. I tried to download this video and it also visible in picker on my phone. I think problem in the MediaStore query or other "filter", that ignore these files, but other apps does not.

NaikSoftware commented 2 years ago

I can debug picker on user's phone in a few days, and would be great to know places where I can see queries or filters, because I dont know where they are. Maybe photo_manager's android native code, etc.

AlexV525 commented 2 years ago

You can set debuggers at lines that return all entities queried from MediaStore, such as: https://github.com/fluttercandies/flutter_photo_manager/blob/2ffa0b70926988570520711c3e0292a292041763/android/src/main/kotlin/top/kikt/imagescanner/core/PhotoManager.kt#L81 And see the info of those videos.

AlexV525 commented 2 years ago

For what I concerning, those videos might have invalid width/height/duration, and a re-download retrieved the info when they're being stored again into MediaStore.

NaikSoftware commented 2 years ago

Sorry, I haven't opportunity to debug user's phone:( I will fix issue if bug is reproduced on my devices.

wuyugege commented 2 years ago

same question, on oppo phone, video produced by record the screen will not show in the photo library, but after you rename the video ,it will show

AlexV525 commented 2 years ago

Seems it's most related to the screen recorder, and the mediastore entry has not been inserted once the recorder done recording.

wuyugege commented 2 years ago

can it be solved? if i use other library ,like _imagespicker ,there is no this question. except this kind of video, some gif files cannot show either

AlexV525 commented 2 years ago

Can you try to debug with native Android, then put the debugger at where the resolver queried assets?

Images filtering could be resolved by ignoreSize.

wuyugege commented 2 years ago

Can you try to debug with native Android, then put the debugger at where the resolver queried assets?

i cannot understand what do yo mean

AlexV525 commented 2 years ago

Nevermind. Which OPPO device you've tested?

wuyugege commented 2 years ago

i tested with oppo a55 5g,i also tested with a hornor 9, there is no this question . i have a gif app, some of my oppo phone users also feedback this question, so i think oppo phone may be special

AlexV525 commented 2 years ago

I do confirm that some videos, especially videos created by screen recorders, are not able to be found with the current queries targeting the MediaStore. Though I'm not sure the root cause, I managed to exclude some conditions:

wuyugege commented 2 years ago

it means that this question cannot be solved temporarily? the package _imagespicker has no this question, maybe it can give you some idea

dev-zhang commented 2 years ago

Hi, I encountered the same problem. When I downloaded some videos from "Xiaohongshu"(小红书) APP to test my app, I can't select them via wechat_assets_picker 6.3.1, the iOS version works fine, the Android version doesn't. What I did:

  1. I found that the video downloaded from "Xiaohongshu"(小红书) APP cannot display the correct duration in the system album of the phone
  2. I downloaded the codes of wechat_assets_picker 6.3.1 and photo_manager 1.3.10 and tested them respectively, then the same problem appeared, these videos still did not appear
  3. After I make some edits to these videos in the system album, such as adjusting their volume, their duration is displayed normally in the system album, and they can be displayed in wechat_assets_picker
  4. In order to troubleshoot the problem, I made some changes to the code of photo_manager, when I changed the query code to bucket_id IS NOT NULL AND ( ( media_type = ? ) OR ( media_type = ? AND duration IS NULL ) ) AND ( date_added > = ? AND date_added <= ? ) or bucket_id IS NOT NULL AND ( ( media_type = ? ) ) AND ( date_added >= ? AND date_added <= ? ) , these videos appeared Hope these can help you solve these problems. thanks.
AlexV525 commented 2 years ago
  1. In order to troubleshoot the problem, I made some changes to the code of photo_manager, when I changed the query code to bucket_id IS NOT NULL AND ( ( media_type = ? ) OR ( media_type = ? AND duration IS NULL ) ) AND ( date_added > = ? AND date_added <= ? ) or bucket_id IS NOT NULL AND ( ( media_type = ? ) ) AND ( date_added >= ? AND date_added <= ? ) , these videos appeared

This clue helps a lot. Applying fix now.

wuyugege commented 2 years ago

i use ^2.0.0-dev.14 now ,but this problem still exist, video produced by record the screen not show in the photo library @AlexV525

AlexV525 commented 2 years ago

See #681 for how to obtain nullable duration videos.

wuyugege commented 2 years ago

you mean: set DurationConstraint(allowNullable: true) for durationConstraint of videoOption, when i call PhotoManager.getAssetPathList? @AlexV525 ,

wuyugege commented 2 years ago

set allowNullable to true is no use , video produced by record the screen still not show in the photo library @AlexV525

AlexV525 commented 2 years ago

set allowNullable to true is no use , video produced by record the screen still not show in the photo library @AlexV525

You might need to follow the same path as https://github.com/fluttercandies/flutter_photo_manager/issues/646#issuecomment-1012830426 suggested, to debug which condition can videos display. We can't reproduce this issue with our local devices, so your debug could be helpful.

wuyugege commented 2 years ago

i dont have ability to revise the code of plugin to debug , but if i rename the video ,it will show in photo library. my device is oppo a55, if you dont have oppo phone , https://open.oppomobile.com/cloudmachine/device/list-plus ,this website maybe help. @AlexV525

AlexV525 commented 2 years ago

but if i rename the video ,it will show in photo library

If it does, this is typically a MediaStore bug, rather than this plugin.

wuyugege commented 2 years ago

but if i use _imagepicker , there is no problem, @AlexV525