fix(android): improve video dimensions extraction #2139
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MediaMetadataRetriever
can directly return the video dimensions, no need to extract a frame for this.Motivation (required)
I was troubleshooting #2138 and noticed that if I commented the dimension-extraction code, it would work fine with 30+ videos.
I am not familiar with Android, but a quick search showed that the video dimensions can be extracted like the other metadata. Switching to the metadata extractor fixed the ANRs I reported in the linked issue.
I am not sure why it was done this way initially this way, maybe @lukebrandonfarrell can provide some context (author of the initial #1891 PR introducing this code)
Test Plan (required)
I tested this using the example app, selection up to 40 videos on my Android 13 phone. This returned the correct dimensions for the files, and did not crash nor cause an ANR.
I did not test in earlier Android, as I dont have any of those on hand.