#1417 do not trust video size and orientation reported by media store

This commit is contained in:
Thibault Deckers 2025-02-04 21:02:12 +01:00
parent bbd819df19
commit bad11564c6
3 changed files with 9 additions and 3 deletions

View file

@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
- editing TIFF metadata increasing file size
- region decoding for some RAW files
- incorrect video size or orientation as reported by Media Store
## <a id="v1.12.2"></a>[v1.12.2] - 2025-01-13

View file

@ -31,8 +31,8 @@ extension ExtraAvesEntryCatalog on AvesEntry {
catalogMetadata = CatalogMetadata(id: id);
} else {
// pre-processing
if ((isVideo && (!isSized || durationMillis == 0)) || mimeType == MimeTypes.avif) {
// exotic video that is not sized during loading
if (isVideo || mimeType == MimeTypes.avif) {
// on initial loading, original source may report incorrect size, rotation or duration
final fields = await VideoMetadataFormatter.getLoadingMetadata(this);
// check size as the video interpreter may fail on some AVIF stills
final width = fields[EntryFields.width];

View file

@ -47,7 +47,7 @@ class VideoMetadataFormatter {
Codecs.webm: 'WebM',
};
// fetch size and duration
// fetch size, rotation and duration
static Future<Map<String, int>> getLoadingMetadata(AvesEntry entry) async {
final mediaInfo = await videoMetadataFetcher.getMetadata(entry);
final fields = <String, int>{};
@ -63,6 +63,11 @@ class VideoMetadataFormatter {
fields[EntryFields.width] = width;
fields[EntryFields.height] = height;
}
final rotationDegrees = sizedStream[Keys.rotate];
if (rotationDegrees is int) {
fields[EntryFields.rotationDegrees] = rotationDegrees;
}
}
}