fix(server): video orientation (#5455)

* fix: video orientation

* pr feedback
This commit is contained in:
martin
2023-12-03 23:34:23 +01:00
committed by GitHub
parent 6d3421a505
commit dfd6846deb
2 changed files with 55 additions and 1 deletions
@@ -14,6 +14,7 @@ import {
IAssetRepository,
ICryptoRepository,
IJobRepository,
IMediaRepository,
IMetadataRepository,
IMoveRepository,
IPersonRepository,
@@ -49,6 +50,17 @@ interface DirectoryEntry {
Item: DirectoryItem;
}
export enum Orientation {
Horizontal = '1',
MirrorHorizontal = '2',
Rotate180 = '3',
MirrorVertical = '4',
MirrorHorizontalRotate270CW = '5',
Rotate90CW = '6',
MirrorHorizontalRotate90CW = '7',
Rotate270CW = '8',
}
type ExifEntityWithoutGeocodeAndTypeOrm = Omit<
ExifEntity,
'city' | 'state' | 'country' | 'description' | 'exifTextSearchableColumn'
@@ -90,6 +102,7 @@ export class MetadataService {
@Inject(IMetadataRepository) private repository: IMetadataRepository,
@Inject(IStorageRepository) private storageRepository: IStorageRepository,
@Inject(ISystemConfigRepository) configRepository: ISystemConfigRepository,
@Inject(IMediaRepository) private mediaRepository: IMediaRepository,
@Inject(IMoveRepository) moveRepository: IMoveRepository,
@Inject(IPersonRepository) personRepository: IPersonRepository,
) {
@@ -182,6 +195,27 @@ export class MetadataService {
const { exifData, tags } = await this.exifData(asset);
if (asset.type === AssetType.VIDEO) {
const { videoStreams } = await this.mediaRepository.probe(asset.originalPath);
if (videoStreams[0]) {
switch (videoStreams[0].rotation) {
case -90:
exifData.orientation = Orientation.Rotate90CW;
break;
case 0:
exifData.orientation = Orientation.Horizontal;
break;
case 90:
exifData.orientation = Orientation.Rotate270CW;
break;
case 180:
exifData.orientation = Orientation.Rotate180;
break;
}
}
}
await this.applyMotionPhotos(asset, tags);
await this.applyReverseGeocoding(asset, exifData);
await this.assetRepository.upsertExif(exifData);