1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-19 18:26:46 +01:00

fix(server): correct media info (#508)

* fix(server): correct media info

* fix(server): video metadata
This commit is contained in:
Thanh Pham 2022-08-21 12:58:47 +07:00 committed by GitHub
parent da9aed5c11
commit 7f9f825589
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 4 deletions

View file

@ -64,7 +64,11 @@ export class AssetUploadedProcessor {
// Extract video duration if uploaded from the web & CLI // Extract video duration if uploaded from the web & CLI
if (asset.type == AssetType.VIDEO) { if (asset.type == AssetType.VIDEO) {
await this.metadataExtractionQueue.add(videoMetadataExtractionProcessorName, { asset }, { jobId: randomUUID() }); await this.metadataExtractionQueue.add(
videoMetadataExtractionProcessorName,
{ asset, fileName, fileSize },
{ jobId: randomUUID() }
);
} }
} }
} }

View file

@ -190,7 +190,7 @@ export class MetadataExtractionProcessor {
@Process({ name: videoMetadataExtractionProcessorName, concurrency: 2 }) @Process({ name: videoMetadataExtractionProcessorName, concurrency: 2 })
async extractVideoMetadata(job: Job<IVideoLengthExtractionProcessor>) { async extractVideoMetadata(job: Job<IVideoLengthExtractionProcessor>) {
const { asset } = job.data; const { asset, fileName } = job.data;
try { try {
const data = await new Promise<ffmpeg.FfprobeData>((resolve, reject) => const data = await new Promise<ffmpeg.FfprobeData>((resolve, reject) =>
@ -222,6 +222,7 @@ export class MetadataExtractionProcessor {
const newExif = new ExifEntity(); const newExif = new ExifEntity();
newExif.assetId = asset.id; newExif.assetId = asset.id;
newExif.description = ''; newExif.description = '';
newExif.imageName = path.parse(fileName).name || null;
newExif.fileSizeInByte = data.format.size || null; newExif.fileSizeInByte = data.format.size || null;
newExif.dateTimeOriginal = createdAt ? new Date(createdAt) : null; newExif.dateTimeOriginal = createdAt ? new Date(createdAt) : null;
newExif.modifyDate = null; newExif.modifyDate = null;
@ -238,13 +239,14 @@ export class MetadataExtractionProcessor {
const match = location.match(locationRegex); const match = location.match(locationRegex);
if (match?.length === 3) { if (match?.length === 3) {
newExif.latitude = parseFloat(match[0]); newExif.latitude = parseFloat(match[1]);
newExif.longitude = parseFloat(match[1]); newExif.longitude = parseFloat(match[2]);
} }
} else if (videoTags && videoTags['com.apple.quicktime.location.ISO6709']) { } else if (videoTags && videoTags['com.apple.quicktime.location.ISO6709']) {
const location = videoTags['com.apple.quicktime.location.ISO6709'] as string; const location = videoTags['com.apple.quicktime.location.ISO6709'] as string;
const locationRegex = /([+-][0-9]+\.[0-9]+)([+-][0-9]+\.[0-9]+)([+-][0-9]+\.[0-9]+)\/$/; const locationRegex = /([+-][0-9]+\.[0-9]+)([+-][0-9]+\.[0-9]+)([+-][0-9]+\.[0-9]+)\/$/;
const match = location.match(locationRegex); const match = location.match(locationRegex);
if (match?.length === 4) { if (match?.length === 4) {
newExif.latitude = parseFloat(match[1]); newExif.latitude = parseFloat(match[1]);
newExif.longitude = parseFloat(match[2]); newExif.longitude = parseFloat(match[2]);

View file

@ -23,6 +23,16 @@ export interface IVideoLengthExtractionProcessor {
* The Asset entity that was saved in the database * The Asset entity that was saved in the database
*/ */
asset: AssetEntity; asset: AssetEntity;
/**
* Original file name
*/
fileName: string;
/**
* File size in byte
*/
fileSize: number;
} }
export interface IReverseGeocodingProcessor { export interface IReverseGeocodingProcessor {